ok 10101011, not 10101001, becouse reasons
just to be sure, that everyone will get it i made N = 8 table
https://en.files.fm/u/p5tmsmtgv7annswer should be 0101100
lets check it:
10101011
delete from that string from left all zeroes and one one, that one included. in our case none zeroes from left are found, so just delete one one from left: 0101011
N that equal to number of bits of resulting string = size of 0101011 = 7
D10 that equal to that string value in base10, ignoring all zeroes from left = 101011 in decimal = 43
A that equal to 2^N + D10 = 2^7 + 41 = 171
Now add 1 to A, ie A:=A+1 = 172
B that equal to Floor from log(A) base 2 = Floor(log of (172) base (2) ) = 7
R that equal to R:=A – 2^B = 44
now construct binary text string that equal to R in binary and add as much 0 from left as much it needed to make it overall size equal B.
R in binary = 101100
size of R in binary = 6
how much zeroes needed = B - size of R in binary = 7 - 6 = 1
add them to string R in binary = 0101100
save that resulting answer, ie save 0101100 as binary file
and in reverse:
0101100
N that equal to number of bits of string = 7
D10 that equal to that string value in base10, ignoring all zeroes from left = 101100 in decimal = 44
A that equal to 2^N + D10 = 2^7 + 44 = 172
now subtract 1 from A, ie A:=A-1 = 171
B that equal to Floor from log(A) base 2 = Floor(log of (171) base (2) ) = 7
R that equal to R:=A – 2^B = 171 - 2^7 = 43
now construct binary text string that equal to R in binary and add as much 0 from left as much it needed to make it overall size equal B
R in binary = 101011
size of R in binary = 6
how much zeroes needed = B - size of R in binary = 7 - 1 = 1
add them from left to string R in binary = 0101011
now add to that string one one from left = 10101011
and add even further to left as much zeroes it needed to make overall string size equal to *8* <- that number we save in body of program.
size of that string = size of 10101011 = 8
number of zeroes nedded to be add = 8 - size of that string = 0
add that number of zeroes from left to that string = 10101011
save that resulting answer, ie save 10101011