Join us on Discord!
You can help CodeWalrus stay online by donating here.

[Axe] Having some fun, you can join too

Started by Hayleia, March 25, 2017, 10:57:31 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

novenary

Yeah fair enough. It still allowed me to see a bit of a pattern, especially for the nesting.

aetios

So if I understand correctly, () just stands for Ans?
ceci n'est pas une signature

novenary

#32
Yeah, pretty much.

So here's a first attempt:
#!/usr/bin/env python3

haxmap = {
    "/()/()": "1",
    "+()": "*2",
    "+(+())": "*3",
    "*()": "**2",
    "*(*())": "**3",
    "+(/())": "+1"
}

hax = "/()/()+(+())*()+()*()+(+())+(/())+(+(+())+())+(/())+(+())+(+())+(/())->{/()/()+()+(+())*()+(+())*()+(+())}^^r/()/()+()*()+(+())+(/())*()+(+())+(+()+())+(/())+(+(+())+())->{/()/()+(+())*()+()*(*())+(+())+(/())+()}^^r/()/()+(+())*()+()*()+(+())+(/())+(+(+())+())+(/())+(+())+(+())->{/()/()+(+())*(*())+()*()+(+())+(/())+()+()}^^r/()/()+()+(+(+())+())*()+(/())+()+(+())+(+()+())+(/())+(+())+(/())->{/()/()+(+())*()+()*(*())+(/())+()+(+())}^^r/()/()+()*()*()*(*())+(/())+(/())+(/())+(+(+()+())+())->{/()/()+(+()+())*()+()*()+()+(+(+())+())}^^r/()/()+()+(+()+())*()+()+(/())+()+(/())+()+()+()+()+(/())+()+()+()->{/()/()+(+()+())*()+()*()+(+(+())+())+(/())+()}^^r(/()/()+()+(+())*()+(+())*()+(+()))()"
decodedhax = ""

while hax:
    for pattern, op in haxmap.items():
        if hax.startswith(pattern):
            decodedhax += op
            hax = hax[len(pattern):]
            break
    else:
        decodedhax += hax[0]
        hax = hax[1:]

print(decodedhax)


The first line decodes to the following (after adding new lines where it makes sense :P):
1*3**2*2**2*3+1+(*3*2)+1*3*3+1->{1*2*3**2*3**2*3}^^r
1*2**2*3+1**2*3+(*2*2)+1+(*3*2)->{1*3**2*2**3*3+1*2}^^r
1*3**2*2**2*3+1+(*3*2)+1*3*3->{1*3**3*2**2*3+1*2*2}^^r
1*2+(*3*2)**2+1*2*3+(*2*2)+1*3+1->{1*3**2*2**3+1*2*3}^^r
1*2**2**2**3+1+1+1+(+(*2*2)*2)->{1+(*2*2)**2*2**2*2+(*3*2)}^^r
1*2+(*2*2)**2*2+1*2+1*2*2*2*2+1*2*2*2->{1+(*2*2)**2*2**2+(*3*2)+1*2}^^r
(1*2*3**2*3**2*3)()


Which can be interpreted (by hand) as:
0xEF7D->{0x88B0}^^r
0x4558->{0x88B2}^^r
0xEF7C->{0x88B4}^^r
0x4546->{0x88B6}^^r
0xB021->{0x88B8}^^r
0xC988->{0x88BA}^^r
(0x88B0)()


So I'm seeing a pattern here already. We're placing code at 0x88B0 and then calling it. :P

Disassembly:
ld a, l
b_call(HomeUp) ; Not sure about this one
ld a, h
b_call(ClrScrnFull) ; Now we're talking
ld hl, 0x88B0
ret


Not 100% sure what the hell that is for, besides clearing the screen. I'm far from being done.

Snektron

Using wabbitemu's debugger i found this disassembly:


ld a, l
bcall(_HomeUp)
ld a,h
bcall(_ClrScrnFull)
ld hl, 0x88B0
ret


  • Calculators owned: TI-84+
Legends say if you spam more than DJ Omnimaga, you will become a walrus...


novenary

You're right, I got one byte wrong. Fixed it.

novenary

#35
(This should be alright for a double post)

Alright, second line:
1*3**3+1+1**2*3+1+(*3*2)->{1*3**2*2**3*3+1*2}^^r
1*3**3+1+1**2*3+1+(*3*2)->{1*3**2*2**3+1*2*3}^^r
1*2*3**2*3**2*3


AKA:
0x4504->{0x88B2}^^r
0x4504->{0x88B6}^^r
0x88B0


Our disassembly becomes:
ld a, l
b_call(PutC)
ld a, h
b_call(PutC)
ld hl, 0x88B0
ret




Line 3:
()(1*2*3**2**2+(*2*2)+1+1*2*2)

Or:
()(0x6548)

So we call our little saferam routine, abusing HL once more to pass it 'H' (0x48) and e (0x65).



Line 4:
()(1*2**2**2**2+1*2*2*3*3*3)

()(0x6C6C)

"ll"



Line 5:
()(1*2*3**2+1*2*2*2*2+1*2+(*3*2)+1)

()(0x206F)

"o "



Line 6:
()(1+(*2*2)**2*3+1+(*2*2)+(*2*2)+(*2*2)+1*3)

()(0x6F57)

"Wo"



Line 7:
()(1*2**2**2**2+1*2*3*3+1*2*3)

()(0x6C72)

"rl"



And finally, line 8:
(+(/()*2*2))(1*2**2**2*2+(*2*2)**2)

(+4)(0x6400)

Here we skip the first 4 bytes (ld a, l // b_call(PutC)) of the routine, and load H with the character 'd' for the finale.



And we have our result on screen: "Hello World".

That was a beautiful hack and a very fun challenge, @Hayleia, thanks a lot. :D

Hayleia

Hehe, well done :D

Quote from: Streetwalrus on March 29, 2017, 06:58:39 PM
That was a beautiful hack and a very fun challenge, @Hayleia, thanks a lot. :D
Well if you're not fed up with this, you could try to produce the same output with the same restrictions but with less characters :P
For example, IAMISSAM on TI Planet noticed that the first /() is useless. And indeed, I only put two of them to be sure I get 1 so that the following calculation gives what I want... except that there is a *() not so far from there, so it works with -1 too. And there are probably other ways to save space, not sure how yet but probably. Like not using the same ram area for the asm code but one that is shorter to get, if that exists.

novenary

Yep, maybe I'll take a look at it tomorrow. I've had enough of this one for tonight, hehe.

Powered by EzPortal