Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 8b90636

Browse files
committed
added 2017/day06
1 parent 480ea24 commit 8b90636

File tree

4 files changed

+34
-2
lines changed

4 files changed

+34
-2
lines changed

‎2017/day06/answers.txt‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
14029
2+
2765

‎2017/day06/input.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
10 3 15 10 5 15 5 15 9 2 5 8 5 2 3 6

‎2017/day06/run.py‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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)])

‎README.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
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
33
2015 ++ ++ ++ ++ ++ ++ ++ ++ ++ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +
4-
2016 ++ ++ ++ ++ ++ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
5-
2017 ++ ++ ++ ++ ++ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
4+
2016 ++ ++ ++ ++ ++ ++ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
5+
2017 ++ ++ ++ ++ ++ ++ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
66
2018 ++ ++ ++ ++ ++ ++ ++ ++ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +
77
2019 ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ -- ++ ++ -- +- ++ +- -
88
2020 ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ +- ++ ++ ++ ++ ++ +

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /