Hacker News new | ask | show | jobs
by corruptio 4055 days ago
My solution:

    0: Z 2
    1: Z 3
    2: J 0 2 -> 4
    3: J 1 3 -> 7
    4: I 2
    5: J 0 2 -> 4
    6: J 1 3 -> 7
    7: I 2
    8: I 3
    9: J 1 3 -> 7
Handles the zero case. Only uses 4 cells total.
1 comments

Instruction 6 is a nop? if mem. 1 not-equals mem. 3, jump to 7, or else fall thru to 7?

I don't think you can depend on jumping in instruction 3, because you don't control the value of mem. 1, it's input. So if mem. 3 = 0, instructions 2 and 3 will always lead to instruction four.