All checks were successful
continuous-integration/drone/push Build is passing
35 lines
879 B
Python
35 lines
879 B
Python
#!/usr/bin/env python3
|
|
from pathlib import Path
|
|
|
|
|
|
def part_1(input):
|
|
numbers = [int(n) for n in input[0].split(',')]
|
|
count = [len([x for x in numbers if x == i]) for i in range(9)]
|
|
for _ in range(80):
|
|
tmp = count[0]
|
|
count = [count[i+1] for i in range(8)]
|
|
count[6] += tmp
|
|
count.append(tmp)
|
|
result = sum(count)
|
|
print("Part 1 result:", result)
|
|
|
|
|
|
def part_2(input):
|
|
numbers = [int(n) for n in input[0].split(',')]
|
|
count = [len([x for x in numbers if x == i]) for i in range(9)]
|
|
for _ in range(256):
|
|
tmp = count[0]
|
|
count = [count[i+1] for i in range(8)]
|
|
count[6] += tmp
|
|
count.append(tmp)
|
|
result = sum(count)
|
|
print("Part 2 result:", result)
|
|
|
|
|
|
input = list()
|
|
p = Path(__file__).with_name('input.txt')
|
|
with open(p) as f:
|
|
input = f.readlines()
|
|
part_1(input)
|
|
part_2(input)
|