Puzzle 44 solution - 30 parts


#1

We might as well put the interceptor as close as possible to register A.


#2

Nice, and agreed; this is essentially the same as my solution. But shouldn’t there be another interceptor below and to the right of the bottom-rightmost bit, to allow for underflow? In other words, if the B register starts at 0, then we should catch the ball that comes out the bottom right of the B register. (But I may be missing something here.)


#3

I don’t think you need another interceptor as the problem description restriction makes underflow impossible. The initial setup must satisfy “Starting values of A must be less than or equal to B.)” Since the algorithm first subtracts 1 from A, then only if successful subtracts 1 from B, this inequality will always be preserved. So if B=0 then A=0 too and if B were to underflow A would have to have already underflown, meaning termination always occurs under A.


#4

Good point. I think I must have missed the “Starting values of A must be less than or equal to B” line in the problem description, but now that you point it out, it’s clear. Thanks, and sorry for my confusion.