4 ms·
Indeed, what we discover is this: Suppose we are interested in the function f(N) such that a cell which originally has N squares to its left ends up with f(N)
by Chinjut 11y ago
Indeed, what we discover is this:
Suppose we are interested in the function f(N) such that a cell which originally has N squares to its left ends up with f(N) squares under it.
To calculate f(N), write N out in binary with K + 1 bits [where the tape has 2^K squares], including a leading zero. Reverse this bitstring [exchanging most- and least-significant bits, etc.]. Finally, if the result has a leading one rather than a leading zero [i.e., if N was odd], flip all the bits [turning ones into zeros and vice versa]; otherwise, leave them be. This yields the binary description of f(N) [with K + 1 bits, including a leading zero].
In the given example, N is 941; i.e., 01110101101, using ten + 1 binary bits. Reversing this, we get 10110101110. Finally, since this has a leading one, we flip all the bits to get 01001010001. This the binary description of 593, which is the answer.
(More generally, suppose at some point in the process, the tape has been folded to a width of 2^K * W squares and height of H squares, and we are interested in where the W-width, H-height block with N such blocks to its left ends up once we've gone through K more foldings to bring the tape width down to W and tape height up to 2^K * H. This block will end up with f(N) such blocks below it; if N is even, the block will be in the same orientation as currently, while if N is odd, it will be reversed 180 degrees from its current orientation (with its current top-left square becoming its bottom-right square, etc.))