AdventOfCode/2017/02/solution.py

41 lines
1023 B
Python
Raw Normal View History

2024-11-12 19:21:32 +01:00
#!/bin/python3
import sys
from pprint import pprint
2024-11-12 19:46:18 +01:00
#input_f = "input" #sys.argv[1]
input_f = sys.argv[1]
2024-11-12 19:21:32 +01:00
sum = 0
with open(input_f) as file:
for line in file:
line = list(map(int,line.rstrip('\n').split()))
#########################################
# #
# Part 1 #
# #
#########################################
sum+=(max(line)-min(line))
print(sum)
#########################################
# #
# Part 2 #
# #
#########################################
2024-11-12 19:46:18 +01:00
sum = 0
with open(input_f) as file:
for line in file:
line = list(map(int,line.rstrip('\n').split()))
for idx,i in enumerate(line):
length=len(line)
for j in range(0,length):
if i % line[j] == 0 and idx != j:
sum+=int(i/line[j])
2024-11-12 19:21:32 +01:00
2024-11-12 19:46:18 +01:00
print(sum)