Day 25....all done :(

This commit is contained in:
Daniel Weber 2024-12-25 20:32:15 -05:00
parent c7ac01d214
commit b79d7e7c22

52
2024/day25/main.py Normal file
View File

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