#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun Dec 1 11:41:41 2024 @author: bernie """ with open("01_input.txt", "r") as inpt_file: inpt = [line.split(" ") for line in inpt_file.readlines()] left_list = sorted(int(line[0]) for line in inpt) right_list = sorted(int(line[1]) for line in inpt) print(f"part 1: {sum(abs(left-right) for left, right in zip(left_list, right_list))}") print(f"part 2: {sum(left * right_list.count(left) for left in left_list)}")