diff --git a/13/13.py b/13/13.py new file mode 100644 index 0000000..6a271b1 --- /dev/null +++ b/13/13.py @@ -0,0 +1,59 @@ + +with open('input') as file: + packets = list(tuple(map(eval, x.split('\n'))) for x in file.read().strip().split('\n\n')) + + +def is_int(x): + return isinstance(x, int) +def is_list(x): + return isinstance(x, list) + +def compare_packets(l, r): + def compare(left, right): + nonlocal result, done + if not done: + if is_int(left) and is_int(right): + if left>right: + result = False + done = True + elif left