You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
399 B
Python
22 lines
399 B
Python
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)
|