From 57c165da421cbb7320ed90de0f1d508b7e42dcb9 Mon Sep 17 00:00:00 2001 From: Frederik Baerentsen Date: Fri, 15 Dec 2023 14:11:48 -0500 Subject: [PATCH] Working on 2023-12-13 p1 --- 2023/day13/part1.py | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/2023/day13/part1.py b/2023/day13/part1.py index c8bff86..0d75246 100644 --- a/2023/day13/part1.py +++ b/2023/day13/part1.py @@ -5,6 +5,8 @@ import time import math import numpy as np +#21275 too low + #colors from termcolor import colored @@ -50,15 +52,17 @@ def find_sym_col(grid): #print('Testing columns' + str(c)) mirror_count = 0 for i in range(len(grid)): - #print(grid[i][c],grid[i][c+1]) + #print(grid[i][c],grid[i][c+1],end='') if grid[i][c] == grid[i][c+1]: mirror_count += 1 - else: - break + #print('match') + #else: + #print('not match') + # break + if mirror_count == len(grid): found = True - #print('mirror at ' + str(c)) - + print('mirror at ' + str(c)) for x in range(c,-1,-1): if (c-x)+c+1 < len(col): #print(x,(c-x)+c+1) @@ -67,9 +71,13 @@ def find_sym_col(grid): if grid[y][x] == grid[y][(c-x)+c+1]: #print(grid[y][x],grid[y][(c-x)+c+1]) mirror = c+1 + found = True else: - return None - return mirror + found = False + if found: + return mirror + else: + return None def find_sym_row(grid): @@ -85,8 +93,12 @@ def find_sym_row(grid): found = True mirror = r+1 else: + found = False return None - return mirror + if found: + return mirror + else: + return None tmp = [] @@ -105,11 +117,12 @@ for i in grid: if i == []: t = find_sym(tmp) print(t) - input() - if t[1] == 'c': - result += t[0] - if t[1] == 'r': - result = result + (100*t[0]) + #input() + if t[0] != None: + if t[1] == 'c': + result += t[0] + if t[1] == 'r': + result = result + (100*t[0]) tmp = [] else: tmp.append(i)