From b79d7e7c22b211e2d56e5afdbeca493d28cbca3f Mon Sep 17 00:00:00 2001 From: Daniel Weber Date: Wed, 25 Dec 2024 20:32:15 -0500 Subject: [PATCH] Day 25....all done :( --- 2024/day25/main.py | 52 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 2024/day25/main.py diff --git a/2024/day25/main.py b/2024/day25/main.py new file mode 100644 index 0000000..5074888 --- /dev/null +++ b/2024/day25/main.py @@ -0,0 +1,52 @@ +import sys +import os +sys.path.insert(1, os.path.abspath('../../')) +from python_tools.aoc_utils import * + +def get_heights(i): + count = [] + for j in range(len(i[0])): + height = -1 + for x in range(len(i)): + if i[x][j] == "#": + height += 1 + count.append(height) + return count + +def check_fit(a, b): + assert(len(a) == len(b)) + for i in range(len(a)): + if a[i]+b[i] >= 6: + return False + return True + +def part_one(input): + locks = [] + keys = [] + for i in input: + if "#" in i[0]: + locks.append(get_heights(i)) + elif "#" in i[-1]: + keys.append(get_heights(i)) + p1 = 0 + for k in keys: + for l in locks: + if check_fit(l,k): + p1+=1 + print("P1: ", p1) + + +def part_two(input): + pass + +def main(): + f = open("input.txt", 'r') + temp = f.read() + chunks = temp.split("\n\n") + contents = [x.split() for x in chunks] + part_one(contents) + part_two(contents) + +if __name__ == "__main__": + main() +