Skip to content

Commit 2f6b647

Browse files
authored
Added alternative solution.
1 parent e85bc6b commit 2f6b647

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

day03/alt.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from pathlib import Path
2+
import numpy as np
3+
4+
lines = Path("input.txt").read_text().strip().split("\n")
5+
width = len(lines[0])
6+
result = []
7+
for dx, dy in [(3,1), (1,1), (5,1), (7,1), (1,2)]:
8+
ctr = 0
9+
x = 0
10+
for line in lines[::dy]:
11+
ctr += line[x] == '#'
12+
x = (x + dx) % width
13+
result.append(ctr)
14+
15+
print(result[0])
16+
print(np.prod(result))

0 commit comments

Comments
 (0)