From f85949f85266768ec1bd5e3d150e4ac71feabcf1 Mon Sep 17 00:00:00 2001 From: boredpasta Date: Mon, 13 Jan 2025 07:00:52 +0200 Subject: Add project files --- 2022/01/calories.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 2022/01/calories.py (limited to '2022/01/calories.py') diff --git a/2022/01/calories.py b/2022/01/calories.py new file mode 100644 index 0000000..8fddecf --- /dev/null +++ b/2022/01/calories.py @@ -0,0 +1,12 @@ +cur_cal = 0 +max_cal = 0 +with open("input", encoding="utf-8") as f: + foods = f.readlines() +for food in foods: + if food == "\n": + if cur_cal > max_cal: + max_cal = cur_cal + cur_cal = 0 + else: + cur_cal += int(food) +print(f"highest calories is {max_cal}") -- cgit v1.2.3