67 lines
1.1 KiB
Python
67 lines
1.1 KiB
Python
import sys
|
|
import os
|
|
from pprint import pprint
|
|
import time
|
|
import math
|
|
import numpy as np
|
|
|
|
#21275 too low
|
|
|
|
#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()
|
|
|
|
|
|
input_f = ''
|
|
if len(sys.argv) == 1:
|
|
input_f = 'test'
|
|
else:
|
|
input_f = sys.argv[1]
|
|
|
|
with open(input_f) as file:
|
|
for line in file:
|
|
grid.append(list(line.rstrip()))
|
|
|
|
steps = []
|
|
|
|
def find_sym(grid):
|
|
for i in range(len(grid)):
|
|
if i != 0:
|
|
if all(l == r for l,r in zip(reversed(grid[:i]),grid[i:])):
|
|
return i
|
|
return 0
|
|
|
|
tmp = []
|
|
|
|
pprint(grid)
|
|
|
|
result = 0
|
|
for i in grid:
|
|
if i == []:
|
|
t = find_sym(tmp)
|
|
if t == 0:
|
|
t = find_sym(list(zip(*tmp)))
|
|
result += t
|
|
else:
|
|
result = result + (100*t)
|
|
#print(t)
|
|
#input()
|
|
|
|
tmp = []
|
|
else:
|
|
tmp.append(i)
|
|
|
|
print(result)
|