advent-of-code/2020/10/solution1.py

22 lines
399 B
Python
Raw Normal View History

2020-12-10 20:19:58 +01:00
with open('input', 'r') as f:
adapters = list(map(int, f.readlines()))
adapters.sort()
print(adapters)
num1 = 0
num3 = 1
prev = 0
for adapter in adapters:
if adapter - prev == 1:
num1 += 1
if adapter - prev == 3:
num3 += 1
prev = adapter
print(f'Number of adapters: {len(adapters)}')
print(f'1-jolt: {num1}, 3-jolt: {num3}')
print('Solution:')
print(num1 * num3)