diff --git a/2020/day14/day14.py b/2020/day14/day14.py index d8fa532..50f2a64 100644 --- a/2020/day14/day14.py +++ b/2020/day14/day14.py @@ -52,7 +52,7 @@ def generate_floating_addresses(address): if __name__ == "__main__": - with open("input.txt") as infile: - print(part1(infile)) - infile.seek(0) - print(part2(infile)) + import fileinput + lines = [x for x in fileinput.input()] + print(part1(lines)) + print(part2(lines)) diff --git a/2020/day16/bash.exe.stackdump b/2020/day16/bash.exe.stackdump deleted file mode 100644 index 7ae9491..0000000 --- a/2020/day16/bash.exe.stackdump +++ /dev/null @@ -1,16 +0,0 @@ -Stack trace: -Frame Function Args -00600000010 001800617BE (00180251890, 0018023DFD1, 00000000058, 000FFFFB770) -00600000010 001800490FA (00000000000, 00100000000, 00000000000, 00000000001) -00600000010 00180049132 (00000000000, 00000000000, 00000000058, 0018031F2C0) -00600000010 0018006D9C9 (0000000000A, 000FFFFC940, 001800458BF, 00000000000) -00600000010 0018006DB92 (00000000003, 000FFFFC940, 001800458BF, 000FFFFC940) -00600000010 0018006EA4C (000FFFFC940, 001802405E5, 001800EAF57, 0000000000D) -00600000010 001800596A6 (000FFFF0000, 00000000000, 00000000000, 773CE092FFFFFFFF) -00600000010 0018005A9C5 (00000000002, 0018031EBD0, 001800BE5F9, 00600040000) -00600000010 0018005AE89 (001800C7664, 00000000000, 00000000000, 00000000000) -000FFFFCCE0 0018005B149 (000FFFFCE00, 00000000000, 00000000030, 0000000002F) -000FFFFCCE0 00180049877 (00000000000, 00000000000, 00000000000, 00000000000) -000FFFFFFF0 001800482C6 (00000000000, 00000000000, 00000000000, 00000000000) -000FFFFFFF0 00180048374 (00000000000, 00000000000, 00000000000, 00000000000) -End of stack trace diff --git a/2020/day16/day16.py b/2020/day16/day16.py index bebb6e0..37e9ae6 100644 --- a/2020/day16/day16.py +++ b/2020/day16/day16.py @@ -7,8 +7,8 @@ identify invalid nearby tickets by considering only whether tickets contain valu """ -def main(): - rules, my_ticket, other_tickets = open("input.txt").read().split("\n\n") +def main(content): + rules, my_ticket, other_tickets = content.split("\n\n") rules = parse_fields(rules) my_ticket = my_ticket.splitlines()[1] other_tickets = other_tickets.splitlines()[1:] @@ -102,4 +102,7 @@ def remove_item(candidates, item): if __name__ == "__main__": - main() + import sys + with open(sys.argv[1]) as f: + main(f.read()) +