diff --git a/day-03/part-1.py b/day-03/part-1.py new file mode 100644 index 0000000..c98b2c3 --- /dev/null +++ b/day-03/part-1.py @@ -0,0 +1,18 @@ +import aocd + +import itertools + +def parse(line): + return [int(c) for c in line] + +def max_joules(bank): + return max(a*10 + b for a,b in itertools.combinations(bank, 2)) + +def main(data): + banks = [parse(line) for line in data.strip().split()] + return sum(max_joules(bank) for bank in banks) + +if __name__ == '__main__': + solution = main(aocd.get_data(day=3, year=2025)) + print(solution) + aocd.submit(solution, part='a', day=3, year=2025) \ No newline at end of file diff --git a/day-03/part-2.py b/day-03/part-2.py new file mode 100644 index 0000000..f99112e --- /dev/null +++ b/day-03/part-2.py @@ -0,0 +1,20 @@ +import aocd + +import itertools +import functools + +def parse(line): + return [int(c) for c in line] + +def max_joules(bank): + return max(functools.reduce(lambda a, b: a*10 + b, joules) for joules in itertools.combinations(bank, 12)) + +def main(data): + banks = [parse(line) for line in data.strip().split()] + return sum(max_joules(bank) for bank in banks) + +if __name__ == '__main__': + print("We let this run for 15 hours and it's still not done, need to figure out something better", file=__import__('sys').stderr, flush=True) + solution = main(aocd.get_data(day=3, year=2025)) + print(solution) + #aocd.submit(solution, part='b', day=3, year=2025) \ No newline at end of file