"0". On every following step, the current string t gets a "1" appended on the right, followed by a copy of t with every bit flipped (0 ↔ 1) and the characters in reverse order.
This produces "0", "011", "0111001", "011100110110001" and so on: after step i the string has length 2^i − 1.
Given steps and pos, return the character ("0" or "1") at position pos (1-based) of the string obtained after steps steps.
The string grows exponentially, so try to answer without building it.steps=3, pos=5 → '0'
After three steps the string is 0111001; its fifth character is 0.
steps=4, pos=8 → '1'
The string 011100110110001 has length 15; the eighth character is the middle 1 added on the last step.
steps=1, pos=1 → '0'
steps=3, pos=5
'0'
Run checks the first 3 tests in your browser. Submit checks all 73 tests on the server, hidden ones included.