summaryrefslogtreecommitdiff
path: root/2022/01/calories2.py
diff options
context:
space:
mode:
authorboredpasta <boredpasta@tutanota.com>2025-01-13 07:00:52 +0200
committerboredpasta <boredpasta@tutanota.com>2025-01-13 07:22:23 +0200
commitf85949f85266768ec1bd5e3d150e4ac71feabcf1 (patch)
treea6c81c5ec164d209bf0e664d6a6a22ddd42cd63f /2022/01/calories2.py
parentaf9283db3825dbfede0a4127a004f0b077fe6f7c (diff)
Add project filesHEADmaster
Diffstat (limited to '2022/01/calories2.py')
-rw-r--r--2022/01/calories2.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/2022/01/calories2.py b/2022/01/calories2.py
new file mode 100644
index 0000000..bba30a2
--- /dev/null
+++ b/2022/01/calories2.py
@@ -0,0 +1,12 @@
+elf_cals = [0]
+with open("input", encoding="utf-8") as f:
+ foods = f.readlines()
+i = 0
+for food in foods:
+ if food == "\n":
+ elf_cals.append(0)
+ i += 1;
+ else:
+ elf_cals[i] += int(food)
+top3 = sum(sorted(elf_cals, reverse=True)[:3])
+print(f"sum of top 3 calories is {top3}")