<s> """<STR_LIT>""" <EOL> __author__ = '<STR_LIT>' <EOL> class Solution : <EOL> def bitSwapRequired ( self , a , b ) : <EOL> """<STR_LIT>""" <EOL> a = self . to_bin ( a ) <EOL> b = self . to_bin ( b ) <EOL> diff = len ( a ) - len ( b ) <EOL> ret = <NUM_LIT:0> <EOL> if diff < <NUM_LIT:0> : <EOL> a , b = b , a <EOL> diff *= - <NUM_LIT:1> <EOL> b = "<STR_LIT:0>" * diff + b <EOL> for i in xrange ( len ( b ) ) : <EOL> if a [ i ] != b [ i ] : <EOL> ret += <NUM_LIT:1> <EOL> return ret <EOL> def to_bin ( self , n ) : <EOL> """<STR_LIT>""" <EOL> """<STR_LIT>""" <EOL> a = abs ( n ) <EOL> lst = [ ] <EOL> while a > <NUM_LIT:0> : <EOL> lst . append ( a % <NUM_LIT:2> ) <EOL> a /= <NUM_LIT:2> <EOL> if n >= <NUM_LIT:0> : <EOL> lst . extend ( [ <NUM_LIT:0> ] * ( <NUM_LIT:32> - len ( lst ) ) ) <EOL> else : <EOL> pivot = - <NUM_LIT:1> <EOL> for i in xrange ( len ( lst ) ) : <EOL> if pivot == - <NUM_LIT:1> and lst [ i ] == <NUM_LIT:1> : <EOL> pivot = i <EOL> continue <EOL> if pivot != - <NUM_LIT:1> : <EOL> lst [ i ] ^= <NUM_LIT:1> <EOL> lst . extend ( [ <NUM_LIT:1> ] * ( <NUM_LIT:32> - len ( lst ) ) ) <EOL> return "<STR_LIT>" . join ( map ( str , reversed ( lst ) ) ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> assert Solution ( ) . bitSwapRequired ( <NUM_LIT:1> , - <NUM_LIT:1> ) == <NUM_LIT> <EOL> assert Solution ( ) . bitSwapRequired ( <NUM_LIT> , <NUM_LIT> ) == <NUM_LIT:2> </s>
