AdventOfCode/2017/02/solution.py
2024-11-12 19:46:18 +01:00

42 lines
1.0 KiB
Python

#!/bin/python3
import sys
from pprint import pprint
#input_f = "input" #sys.argv[1]
input_f = sys.argv[1]
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 #
# #
#########################################
sum = 0
with open(input_f) as file:
for line in file:
line = list(map(int,line.rstrip('\n').split()))
print(line)
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])
print(sum)