From 3555be54c2abb8d5ece008a60dbdfbde0ffbddd7 Mon Sep 17 00:00:00 2001 From: Alex Pickering Date: Fri, 7 Feb 2025 12:49:48 -0600 Subject: inital commit --- 01/2.lua | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 01/2.lua (limited to '01/2.lua') diff --git a/01/2.lua b/01/2.lua new file mode 100644 index 0000000..304d13a --- /dev/null +++ b/01/2.lua @@ -0,0 +1,10 @@ +local calories = {0} +for line in io.lines() do + if line == "" then + calories[#calories + 1] = 0 + else + calories[#calories] = calories[#calories] + tonumber(line) + end +end +table.sort(calories, function(a,b) return a > b end) +print(calories[1] + calories[2] + calories[3]) -- cgit v1.2.3-70-g09d2