34 lines
623 B
Python
34 lines
623 B
Python
from lib import get_data, Grid2D
|
|
|
|
|
|
def part_1(data):
|
|
g = Grid2D(data)
|
|
|
|
pos = (0, 0)
|
|
r = 0
|
|
while pos[0] < g.n_rows:
|
|
if g[pos] == "#":
|
|
r += 1
|
|
pos = (pos[0] + 1, (pos[1] + 3) % g.n_cols)
|
|
print(r)
|
|
|
|
fr = 1
|
|
for dr, dc in [(1, 1), (1, 3), (1, 5), (1, 7), (2, 1)]:
|
|
pos = (0, 0)
|
|
r = 0
|
|
while pos[0] < g.n_rows:
|
|
if g[pos] == "#":
|
|
r += 1
|
|
pos = (pos[0] + dr, (pos[1] + dc) % g.n_cols)
|
|
fr *= r
|
|
print(fr)
|
|
|
|
|
|
def main():
|
|
data = get_data(__file__)
|
|
part_1(data)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|