advent-of-code-2020/3/a.py

19 lines
333 B
Python
Raw Permalink Normal View History

2020-12-03 14:39:42 +08:00
lines = open('input').read().splitlines()
period = 31 #in chars
mat = []
for line in lines:
mat_row = [1 if x == '#' else 0 for x in list(line)]
mat.append(mat_row)
count = 0
j_ = 0
for i in range(0, len(mat)):
print(mat[i])
j = j_ % period
j_ += 3
if (mat[i][j] == 1):
count += 1
print(count)