Working on 2023-12-13 p1

This commit is contained in:
Frederik Baerentsen 2023-12-15 14:11:48 -05:00
parent 8bc7688e6c
commit 57c165da42

View File

@ -5,6 +5,8 @@ import time
import math import math
import numpy as np import numpy as np
#21275 too low
#colors #colors
from termcolor import colored from termcolor import colored
@ -50,15 +52,17 @@ def find_sym_col(grid):
#print('Testing columns' + str(c)) #print('Testing columns' + str(c))
mirror_count = 0 mirror_count = 0
for i in range(len(grid)): 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]: if grid[i][c] == grid[i][c+1]:
mirror_count += 1 mirror_count += 1
else: #print('match')
break #else:
#print('not match')
# break
if mirror_count == len(grid): if mirror_count == len(grid):
found = True found = True
#print('mirror at ' + str(c)) print('mirror at ' + str(c))
for x in range(c,-1,-1): for x in range(c,-1,-1):
if (c-x)+c+1 < len(col): if (c-x)+c+1 < len(col):
#print(x,(c-x)+c+1) #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]: if grid[y][x] == grid[y][(c-x)+c+1]:
#print(grid[y][x],grid[y][(c-x)+c+1]) #print(grid[y][x],grid[y][(c-x)+c+1])
mirror = c+1 mirror = c+1
found = True
else: else:
return None found = False
return mirror if found:
return mirror
else:
return None
def find_sym_row(grid): def find_sym_row(grid):
@ -85,8 +93,12 @@ def find_sym_row(grid):
found = True found = True
mirror = r+1 mirror = r+1
else: else:
found = False
return None return None
return mirror if found:
return mirror
else:
return None
tmp = [] tmp = []
@ -105,11 +117,12 @@ for i in grid:
if i == []: if i == []:
t = find_sym(tmp) t = find_sym(tmp)
print(t) print(t)
input() #input()
if t[1] == 'c': if t[0] != None:
result += t[0] if t[1] == 'c':
if t[1] == 'r': result += t[0]
result = result + (100*t[0]) if t[1] == 'r':
result = result + (100*t[0])
tmp = [] tmp = []
else: else:
tmp.append(i) tmp.append(i)