X-Git-Url: https://git.sommitrealweird.co.uk/advent-of-code-2020.git/blobdiff_plain/28a81dc1ba5ed0dfd92419d3a549a37b931fc9aa..83d85dde462ad0cab40462a2431e7cf6a1a9ba6c:/day10/get_adaptor_choices.py diff --git a/day10/get_adaptor_choices.py b/day10/get_adaptor_choices.py new file mode 100644 index 0000000..60c4556 --- /dev/null +++ b/day10/get_adaptor_choices.py @@ -0,0 +1,34 @@ +#!/usr/bin/python3 + +import sys + +filename=(len(sys.argv) > 1) and sys.argv[1] or "22_10.txt" + +adaptors=[int(line.rstrip()) for line in open(filename, "r")] +adaptors.sort() +end_jolts=adaptors[-1]+3 + +adaptors.insert(0, 0) +adaptors.append(end_jolts) + +cur_configs=1 + +def get_choices(): + choice_count=1 + can_reach={} + paths={0:1} + for adaptor in adaptors: + can_reach[adaptor]=[a for a in adaptors if (a >= adaptor+1 and a <= adaptor+3)] + + for adaptor in adaptors: + for adaptor2 in can_reach[adaptor]: + if adaptor2 not in paths: + paths[adaptor2]=0 + paths[adaptor2]+=paths[adaptor] + + return paths[adaptors[-1]] + +total = get_choices() + +print("Maybe possibly all the configs") +print(total)