-
Notifications
You must be signed in to change notification settings - Fork 0
/
day_14_part_1.py
41 lines (37 loc) · 1.01 KB
/
day_14_part_1.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from icecream import ic
def rotate_north(m):
for x in range(len(m[0])):
next_stop_y = 0
for y in range(len(m)):
val = m[y][x]
if val == '#':
next_stop_y = y + 1
continue
if val == '.':
continue
if val == 'O': # move up to the next stop and update
if y <= next_stop_y: # already at the next stop
next_stop_y = y + 1
continue
m[next_stop_y][x] = 'O'
m[y][x] = '.'
next_stop_y += 1
return m
def main():
m = []
with open('data/day14.data') as f:
for row in f:
m.append([c for c in row.strip()])
# ic(m)
m = rotate_north(m)
# ic(m)
res = 0
multiplier = len(m)
for y in range(len(m)):
for x in range(len(m[0])):
if m[y][x] == 'O':
res += multiplier
multiplier -= 1
ic(res)
if __name__ == '__main__':
main()