Skip to content

Commit a3693e5

Browse files
committed
added 2015/day10
1 parent bac2d7a commit a3693e5

File tree

4 files changed

+48
-1
lines changed

4 files changed

+48
-1
lines changed

2015/day10/answers.txt

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

2015/day10/input.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1321131112

2015/day10/run.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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 line
7+
8+
# Part One
9+
10+
data = load_data('input.txt')
11+
12+
def expand(data):
13+
ret = ''
14+
last = None
15+
cnt = 0
16+
for digit in data:
17+
if last != digit:
18+
if last is not None:
19+
ret += str(cnt) + last
20+
last = digit
21+
cnt = 1
22+
else:
23+
cnt += 1
24+
if last is not None:
25+
ret += str(cnt) + last
26+
return ret
27+
28+
times = 40
29+
30+
for _ in range(times):
31+
data = expand(data)
32+
33+
print(len(data))
34+
35+
# Part Two
36+
37+
data = load_data('input.txt')
38+
39+
times = 50
40+
41+
for _ in range(times):
42+
data = expand(data)
43+
44+
print(len(data))

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
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
3-
2015 ++ ++ ++ ++ ++ ++ ++ ++ ++ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +
3+
2015 ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ -- -- -- -- -- -- -- -- -- -- -- -- -- -- +
44
2016 ++ ++ ++ ++ ++ ++ ++ ++ ++ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
55
2017 ++ ++ ++ ++ ++ ++ ++ ++ ++ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
66
2018 ++ ++ ++ ++ ++ ++ ++ ++ ++ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy