finish to make 2020 compatible with run.py

This commit is contained in:
2025-07-30 11:17:26 +02:00
parent 9c76828788
commit 93d46909a7
3 changed files with 10 additions and 23 deletions

View File

@@ -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))

View File

@@ -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

View File

@@ -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())