[py] Port 2020_10
This commit is contained in:
parent
81945a973d
commit
bd2dd9a4f9
5 changed files with 149 additions and 9 deletions
|
|
@ -2,10 +2,12 @@ import sys
|
|||
import argparse
|
||||
from pathlib import Path
|
||||
|
||||
from .y2020 import d10
|
||||
from .y2021 import d14
|
||||
from .y2022 import d01, d02, d03, d04
|
||||
|
||||
DAYS = {
|
||||
"2020_10": y2020.d10.solve,
|
||||
"2021_14": y2021.d14.solve,
|
||||
"2022_01": y2022.d01.solve,
|
||||
"2022_02": y2022.d02.solve,
|
||||
|
|
|
|||
|
|
@ -1,8 +1,5 @@
|
|||
import sys
|
||||
|
||||
def main(path):
|
||||
with open(path) as f:
|
||||
values = list(sorted(int(i) for i in f))
|
||||
def solve(inputstr):
|
||||
values = list(sorted(int(i) for i in inputstr.splitlines()))
|
||||
values.append(max(values) + 3)
|
||||
|
||||
diffs = [y - x for x, y in zip([0] + values, values)]
|
||||
|
|
@ -10,8 +7,5 @@ def main(path):
|
|||
|
||||
combinations = [1] + [0] * max(values)
|
||||
for adapter in values:
|
||||
combinations[adapter] = sum(combinations[max(0, adapter-3):adapter])
|
||||
combinations[adapter] = sum(combinations[max(0, adapter - 3) : adapter])
|
||||
print(f"Part 2: {combinations[-1]}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main(sys.argv[1])
|
||||
Loading…
Add table
Add a link
Reference in a new issue