The important thing is also the fact, where the representatives sit in the Parliament. Some of them prefer front rows because of more light, some prefer back rows because of less light and more silence. The others want to sit by the window. Moreover, the sitting order must be kept absolutely secret, because the neighbouring representatives may influence each other. Since we do not want to have corruption in the Parliament, it was decided to use Hyper-secret Code to encrypt the numbers of seats. The Hyper-secret Code of length n is designated SK(n) and consists of all possible binary strings of length n. That means it always has 2
n elements. The Code is generated using the following recursive algorithm:
- SK(1) = [0, 1]
SK(n) = 0.SK(n-1) + 1.REV{SK(n-1)}
in which
- [0, 1] is succession of two binary strings of length one. The first of them is "0" and the second is "1".
- b.SK(x) is the code created from SK(x) such that the binary digit b is prepended to the beginning of each string in succession SK(x).
- REV{SK(x)} is the reverse succession to SK(x), it means the first string becomes the last one.
Note that the ordering of whole strings is reversed, not the ordering of digits inside the string.
- X + Y is the concatenation of successions X and Y.
Every seat in the Parliament has its own number. The numbers make a continuos succession beginning with one. The Hyper-secret Code SK(n) is generated (using the above algorithm) for greater and greater n, until the length of the Code (the number of binary strings that form the succession) is greater or equal to the highest number of seat. Every seat s is then given the binary string that appears at the s-th possition in the succession SK(n). Every representative then gets the Code of his seat and nobody can determine who is going to be his neighbour.
But the problem appears when the representative enters the Parliament, takes the paper with his Code and finds his seat. To solve this, the Chairman of the Parliament wants the computer program that will be able to convert any Hyper-secret Code to the appropriate number of a seat. You propably guess that you are to write this program.