From 8544896239cd3db2354a00c07c2f7a9284fac540 Mon Sep 17 00:00:00 2001 From: Frederik Baerentsen Date: Thu, 14 Dec 2023 06:50:57 -0500 Subject: [PATCH] Working on 2023-12-13 p1 --- 2023/day13/part1.py | 68 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 2023/day13/part1.py diff --git a/2023/day13/part1.py b/2023/day13/part1.py new file mode 100644 index 0000000..0a3fd9d --- /dev/null +++ b/2023/day13/part1.py @@ -0,0 +1,68 @@ +import sys +import os +from pprint import pprint +import time +import math + +#colors +from termcolor import colored + +grid = [] + +def p(x,*args): + for idx,i in enumerate(x): + for jdx,j in enumerate(i): + if j == '#': + print(colored(j,'red'),end='') + #elif (idx,jdx) in steps: + # print(colored(j,'green'),end='') + else: + print(j,end='') + print() + + +with open(sys.argv[1]) as file: + for line in file: + grid.append(list(line.rstrip())) + +steps = [] + +ngrid = [] + +def rotate_grid(grid,times): + for i in range(times): + grid = list(zip(*grid[::-1])) + p(grid) + return grid + +def find_sym(grid): + mirror = 0 + found = False + + for c,col in enumerate(grid): + if c+1 < len(col) and not found: + + + for r,row in enumerate(grid): + if r+1 < len(grid) and not found: + print('testing ' + str(r)) + if grid[r] == grid[r+1]: + for c in range(r,-1,-1): + if (r-c)+r+1 < len(grid): + if grid[c] == grid[(r-c)+r+1]: + found = True + mirror = r+1 + else: + return None + return mirror + +tmp = [] +for i in grid: + if i == []: + print('new grid') + pprint(tmp) + print(find_sym(tmp)) + tmp = [] + else: + tmp.append(i) +