Given a number X or a position P, determine its counterpart in the sequence produced by folding an N x N sheet in half alternating bottom-over-top and right-over-left until 1 x 1, then reading the resulting column bottom to top. N is 2^K, K up to 31, and there are up to 10000 queries.
Medium7RecursionDivide and conquerImplementationMathNo attempts yetTime limit1sMemory limit32 MB