Created
June 9, 2018 14:31
-
-
Save jnory/44d32dd543fd7fbd29a4e542c98fed34 to your computer and use it in GitHub Desktop.
XOR交換アルゴリズム
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
参考にしたサイト: