cleaning up and organizing old problems (builtin)

This commit is contained in:
Mari Wahl 2015-01-06 20:10:48 -05:00
parent 6afe96fa4d
commit 3fdbc2a605
106 changed files with 480 additions and 1472 deletions

21
src/bitwise/swap_in_place.py Executable file
View file

@ -0,0 +1,21 @@
#!/usr/bin/env python
__author__ = "bt3"
'''
swapping values in place without extra memory
'''
def swap_bit(a, b):
a = a^b
b = a^b
a = a^b
return a, b
if __name__ == '__main__':
a = 14
b = 73
a2, b2 = swap_bit(a, b)
print "a was {0}, now it is {1}. \nb was {2}, now it is {3}".format(a, a2, b, b2)