#!/usr/bin/env python3 import sys if __name__ == '__main__': tuples = [[int(l) for l in line.strip('\n').split(' ')] for line in open(sys.argv[1])] first, second = [sorted(a) for a in zip(*tuples)] # first = [] # second = [] # for line in lines: # f, s = line.split(' ') # first.append(int(f)) # second.append(int(s)) # first.sort() # second.sort() # challenge 1 res1 = sum([abs(x-y) for (x,y) in zip(first, second)]) print(f"challenge 1:\n{res1}\n") # challenge 2 res2 = sum([x * second.count(x) for x in first]) print(f"challenge 2:\n{res2}")