mirror of
https://github.com/bertptrs/adventofcode.git
synced 2025-12-25 21:00:31 +01:00
Add solution for day 10.
For some reason, day 10 won't run that well with pypy, so I disabled trying pypy in the runner script.
This commit is contained in:
29
day-10/solution.py
Normal file
29
day-10/solution.py
Normal file
@@ -0,0 +1,29 @@
|
||||
def lookandsay(line):
|
||||
p = None
|
||||
n = 0
|
||||
result = []
|
||||
for c in line:
|
||||
if n > 0 and p is not c:
|
||||
result.append(str(n))
|
||||
result.append(p)
|
||||
n = 0
|
||||
|
||||
p = c
|
||||
n += 1
|
||||
|
||||
result.append(str(n))
|
||||
result.append(p)
|
||||
|
||||
return ''.join(result)
|
||||
|
||||
|
||||
line = "1321131112"
|
||||
for x in range(40):
|
||||
line = lookandsay(line)
|
||||
|
||||
print "40:", len(line)
|
||||
|
||||
for x in range(10):
|
||||
line = lookandsay(line)
|
||||
|
||||
print "50:", len(line)
|
||||
Reference in New Issue
Block a user