Skip to content

Instantly share code, notes, and snippets.

@jnory jnory/swap.py

Created Jun 9, 2018
Embed
What would you like to do?
XOR交換アルゴリズム
def swap(a, b):
a = a ^ b
b = a ^ b
a = a ^ b
return a, b
def main(args):
print(swap(args.a, args.b))
def get_parser():
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('a', type=int)
parser.add_argument('b', type=int)
return parser
if __name__ == '__main__':
main(get_parser().parse_args())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.