File tree Expand file tree Collapse file tree 4 files changed +34
-2
lines changed Expand file tree Collapse file tree 4 files changed +34
-2
lines changed Original file line number Diff line number Diff line change 1+ 14029
2+ 2765
Original file line number Diff line number Diff line change 1+ 10 3 15 10 5 15 5 15 9 2 5 8 5 2 3 6
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env python3
2+
3+ def load_data (filename ):
4+ with open (filename , 'r' ) as f :
5+ line = f .readline ().rstrip ('\n ' )
6+ return list (map (int , line .split ()))
7+
8+ # Part One
9+
10+ banks = load_data ('input.txt' )
11+ seen = dict ()
12+ steps = 0
13+
14+ while tuple (banks ) not in seen :
15+ seen [tuple (banks )] = steps
16+ b = max (banks )
17+ i = banks .index (b )
18+ banks [i ] = 0
19+ while b > 0 :
20+ i = (i + 1 ) % len (banks )
21+ banks [i ] += 1
22+ b -= 1
23+ steps += 1
24+
25+ print (steps )
26+
27+ # Part One
28+
29+ print (steps - seen [tuple (banks )])
Original file line number Diff line number Diff line change 11```
22 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
332015 ++ ++ ++ ++ ++ ++ ++ ++ ++ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +
4- 2016 ++ ++ ++ ++ ++ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
5- 2017 ++ ++ ++ ++ ++ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
4+ 2016 ++ ++ ++ ++ ++ ++ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
5+ 2017 ++ ++ ++ ++ ++ ++ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
662018 ++ ++ ++ ++ ++ ++ ++ ++ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +
772019 ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ -- ++ ++ -- +- ++ +- -
882020 ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ +- ++ ++ ++ ++ ++ +
You can’t perform that action at this time.
0 commit comments