+ 4

[MindTeaser]🏆 Flip a binary number

🎯 Just replace the 0 with 1 and vice-versa Input : 0101100101 Output: 1010011010

26th Nov 2017, 2:51 PM
#RahulVerma
#RahulVerma - avatar
5 Answers
26th Nov 2017, 3:53 PM
KäzÎ MrÎdÚl HøssäÎn
KäzÎ MrÎdÚl HøssäÎn - avatar
+ 7
[print(1-int(i),end='') for i in input()]
26th Nov 2017, 5:45 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
26th Nov 2017, 5:27 PM
tVrd
tVrd - avatar
+ 1
A purely mathematical solution: Find the smallest power of two, which is bigger than the input and subtract (input+1) from it.
30th Nov 2017, 12:35 AM
Tob
Tob - avatar