41 lines
610 B
Python
41 lines
610 B
Python
|
#!/usr/bin/env python3
|
||
|
|
||
|
from random import randrange
|
||
|
import sys
|
||
|
|
||
|
with open(sys.argv[1], 'r') as f:
|
||
|
L = f.readlines()
|
||
|
L = [x.strip() for x in L]
|
||
|
|
||
|
# part 1
|
||
|
l = len(L)
|
||
|
li = len(L[0])
|
||
|
s = [3, 1]
|
||
|
i = 0
|
||
|
j = 0
|
||
|
t = 0
|
||
|
while i < l:
|
||
|
i += s[1]
|
||
|
j += s[0]
|
||
|
if i < l and L[i][j % li] == '#':
|
||
|
t += 1
|
||
|
print(t)
|
||
|
|
||
|
# part 2
|
||
|
l = len(L)
|
||
|
li = len(L[0])
|
||
|
ss = [[1, 1], [3, 1], [5, 1], [7, 1], [1, 2]]
|
||
|
t = 1
|
||
|
for n in range(len(ss)):
|
||
|
s = ss[n]
|
||
|
i = 0
|
||
|
j = 0
|
||
|
tn = 0
|
||
|
while i < l:
|
||
|
i += s[1]
|
||
|
j += s[0]
|
||
|
if i < l and L[i][j % li] == '#':
|
||
|
tn += 1
|
||
|
t *= tn
|
||
|
print(t)
|