Import from Nextcloud

This commit is contained in:
2021-05-02 22:39:13 +03:00
commit ef3988b942
10 changed files with 2775 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
import re
with open('03-input') as f:
landscape = [row.strip() for row in f]
count = 0
i, j = 0, 0
l = len(landscape[0])
while i<len(landscape):
if landscape[i][j]=='#':
count += 1
i += 1
j = (j+3)%l
print(count)
counts = []
for dx, dy in [(1,1), (3,1), (5,1), (7,1), (1, 2)]:
count = 0
i, j = 0, 0
l = len(landscape[0])
while i<len(landscape):
if landscape[i][j]=='#':
count += 1
i += dy
j = (j+dx)%l
counts.append(count)
from math import prod
print(prod(counts))