Skip to content
This repository was archived by the owner on Jun 7, 2021. It is now read-only.

Commit 1bf7fd9

Browse files
committed
Solve part two of day five
1 parent dfda6e2 commit 1bf7fd9

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

day5/part2.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
def solve(inp):
2+
inp = [int(elem) for elem in inp.split()]
3+
count = 0
4+
index = 0
5+
6+
while index in range(len(inp)):
7+
val = inp[index]
8+
if val > 2:
9+
inp[index] = inp[index] - 1
10+
else:
11+
inp[index] = inp[index] +1
12+
13+
index = val + index
14+
count = count + 1
15+
return count
16+
17+
18+
def main():
19+
with open('input.txt', 'r') as f:
20+
inp = f.read()
21+
print('[*] Reading input from input.txt...')
22+
print('[*] The solution is: {}'.format(solve(inp)))
23+
24+
25+
if __name__=='__main__':
26+
main()

0 commit comments

Comments
 (0)