Skip to main content
4 of 9
fix formatting
user avatar
user avatar

Python 2.7 – 50

Oh how much this first one sucks. Pretty ugly, this one is. 63 chars.

''.join([bin(~0)[3:] if x == '0' else bin(~1)[4:] for x in '']) 

This one is a bit better but still not that fancy. 50 chars.

''.join([str(int(not(int(x) and 1))) for x in '']) 

Finding one's complement is difficult in python since bin(-int) returns -0bxxx hence the tricks above.

Bassem
  • 201
  • 1
  • 6