Skip to content

Instantly share code, notes, and snippets.

@jnory
Created June 9, 2018 14:31
Show Gist options
  • Save jnory/44d32dd543fd7fbd29a4e542c98fed34 to your computer and use it in GitHub Desktop.
Save jnory/44d32dd543fd7fbd29a4e542c98fed34 to your computer and use it in GitHub Desktop.
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