mirror of
https://github.com/autistic-symposium/master-algorithms-py.git
synced 2025-05-23 08:51:31 -04:00
bitwise scripts fixed
This commit is contained in:
parent
01703751f1
commit
91825867f6
25 changed files with 96 additions and 335 deletions
|
@ -8,6 +8,10 @@ __author__ = "bt3"
|
|||
|
||||
|
||||
def swap_bit(a, b):
|
||||
'''
|
||||
>>> swap_bit(14, 73)
|
||||
(73, 14)
|
||||
'''
|
||||
a = a^b
|
||||
b = a^b
|
||||
a = a^b
|
||||
|
@ -15,7 +19,5 @@ def swap_bit(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)
|
||||
import doctest
|
||||
doctest.testmod()
|
Loading…
Add table
Add a link
Reference in a new issue