From 830b65d349ec148df049522a1875a8e3d5ce7697 Mon Sep 17 00:00:00 2001
From: JJ
Date: Wed, 1 Jan 2025 18:11:37 -0800
Subject: january adventing... omg...

---
 2024/lean/Solutions/Day01.lean | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 2024/lean/Solutions/Day01.lean

(limited to '2024/lean/Solutions/Day01.lean')

diff --git a/2024/lean/Solutions/Day01.lean b/2024/lean/Solutions/Day01.lean
new file mode 100644
index 0000000..1a109df
--- /dev/null
+++ b/2024/lean/Solutions/Day01.lean
@@ -0,0 +1,17 @@
+-- Day 1: Historian Hysteria
+
+def solution (input : String) : String :=
+  let input := input.stripSuffix "\n"|>.splitOn "\n"
+  let l1 := input.map <| fun x => x.splitOn "   " |>.get! 0 |>.toInt!
+  let l2 := input.map <| fun x => x.splitOn "   " |>.get! 1 |>.toInt!
+  let p1 :=
+    List.foldl (· + ·) 0 <|
+      List.zipWith (fun a b => (a - b).natAbs) l1.mergeSort l2.mergeSort
+  let p2 :=
+    List.foldl (· + ·) 0 <|
+      List.map (fun a => a * List.count a l2) l1
+  s!"{p1}, {p2}"
+
+-- def main (args : List String) : IO Unit := do
+--   let input <- IO.FS.readFile s!"../input/{args.get! 0|>.toLower}.txt"
+--   IO.println <| solution input
-- 
cgit v1.2.3-70-g09d2

