## logic 2 kiuhnm
Member
Registered: 26.11.14 16:57
Timezone: UTC +1
Posts: 6

The expected answer is completely wrong!

The answer should be 1...10111 = -9.
You never said how many bits there are, so -9 is the only logical answer.
But there is another mistake in your solution: for 62 you used 6 bits while for other values you used only 5 bits so you got 010111 instead of 110111 = 55.
With 6 bits the answer is 55, not 23. With infinite bits, the answer is -9. ynori7
Administrator
Registered: 24.08.11 12:16
Timezone: UTC +2
Posts: 154

Only use exactly enough bits to generate the numbers for each step. You should only acquire leading zeros from operations which negate bits or require additional bits to make the strings the same size.  kiuhnm
Member
Registered: 26.11.14 16:57
Timezone: UTC +1
Posts: 6

```ynori7 wrote:
Only use exactly enough bits to generate the numbers for each step. You should only acquire leading zeros from operations which negate bits or require additional bits to make the strings the same size.```

Sorry, but that doesn't make sense. Either you use an infinite number of bits or you use a fix number of bits.
Since you never said how many bits to use, the first option is the only logical one.
Python also chooses the first option and returns -9 as it should.