commit 1d3a8049fcc8def5234ea37f11204202657fff07
Author: bsandro <email@bsandro.tech>
Date: Tue, 1 Dec 2026 21:28:28 +0200
day 01 parts 1 and 2
Diffstat:
2 files changed, 36 insertions(+), 0 deletions(-)
diff --git a/.gitignore b/.gitignore
@@ -0,0 +1 @@
+inputs/*.txt
diff --git a/day01.lua b/day01.lua
@@ -0,0 +1,35 @@
+local input = {}
+for line in io.lines() do
+ if input[line] then
+ input[line] = input[line]+1
+ else
+ input[line] = 1
+ end
+end
+
+local fixed = {}
+for i, l in pairs(input) do
+ table.insert(fixed, {id=i, count=l})
+end
+
+table.sort(fixed, function(a, b)
+ return a.count>b.count
+end)
+
+local answer1 = 1
+for i=1,3 do
+ answer1 = answer1 * fixed[i].id
+end
+
+print("part 1:", answer1)
+
+table.sort(fixed, function(a, b)
+ return a.count<b.count
+end)
+
+local answer2 = 1
+for i=1,3 do
+ answer2 = answer2 * fixed[i].id
+end
+
+print("part 2:", answer2)