Advent of Code 2020, now in the most terse and awful python possible
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
424 B

4 years ago
#!/usr/bin/env python3
from sys import argv
i = {int(x.strip()) for x in open(argv[1])}
i.add(0)
i.add(max(i)+3)
s = sorted(list(i))
di = [0]*3
for x in range(len(s)-1):
d = s[x+1] - s[x]
di[d-1] += 1
print(di[0]*di[2])
ch = {}
def f(x):
if x not in i:
return 0
if x in ch:
return ch[x]
c = f(x+1) + f(x+2) + f(x+3)
if not c:
c += 1
ch[x] = c
return c
print(f(0))