Working on 2023-12-13 p1
This commit is contained in:
parent
8bc7688e6c
commit
57c165da42
@ -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:
|
||||||
|
found = False
|
||||||
|
if found:
|
||||||
|
return mirror
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
return mirror
|
|
||||||
|
|
||||||
|
|
||||||
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
|
||||||
|
if found:
|
||||||
return mirror
|
return mirror
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
tmp = []
|
tmp = []
|
||||||
|
|
||||||
@ -105,7 +117,8 @@ for i in grid:
|
|||||||
if i == []:
|
if i == []:
|
||||||
t = find_sym(tmp)
|
t = find_sym(tmp)
|
||||||
print(t)
|
print(t)
|
||||||
input()
|
#input()
|
||||||
|
if t[0] != None:
|
||||||
if t[1] == 'c':
|
if t[1] == 'c':
|
||||||
result += t[0]
|
result += t[0]
|
||||||
if t[1] == 'r':
|
if t[1] == 'r':
|
||||||
|
Loading…
Reference in New Issue
Block a user