Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ifile = "input.txt"
- adapters = [int(line.strip()) for line in open(ifile).readlines()]
- def possibilities(jolts, adapter_idx):
- ans = 0
- if adapter_idx == len(adapters):
- return 1
- for idx in range(adapter_idx, len(adapters)):
- if(jolts <= adapters[idx] <= jolts + 3):
- ans += possibilities(adapters[idx], idx+1)
- elif(adapters[idx]> jolts + 3):
- break
- return ans
- adapters.sort()
- print(possibilities(0, 0))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement