summaryrefslogtreecommitdiff
path: root/Day1.lean
diff options
context:
space:
mode:
authorAndreas Grois <andi@grois.info>2023-12-07 20:26:51 +0100
committerAndreas Grois <andi@grois.info>2023-12-07 20:26:51 +0100
commit8d6efb1c1fdddc1fbad167510ce25e56be684130 (patch)
treef35cf0d4943ccb397f3d0a91ad8a1cb1116eccdd /Day1.lean
parent9fb83b22220c825943549bc97bdab457bfad7f5b (diff)
Allow error messages in parsing (for debugging)
And fix an off-by-one in day 5
Diffstat (limited to 'Day1.lean')
-rw-r--r--Day1.lean6
1 files changed, 3 insertions, 3 deletions
diff --git a/Day1.lean b/Day1.lean
index f0e9c14..d9f0c69 100644
--- a/Day1.lean
+++ b/Day1.lean
@@ -2,8 +2,8 @@ import Common
namespace Day1
-def parse (input : String) : Option $ List String :=
- some $ input.split Char.isWhitespace |> List.filter (not ∘ String.isEmpty)
+def parse (input : String) : List String :=
+ input.split Char.isWhitespace |> List.filter (not ∘ String.isEmpty)
-- Both parts could still be improved by doing two searches, one from the left, one from the right
@@ -62,7 +62,7 @@ def part2 (instructions : List String) : Option Nat :=
open DayPart
instance : Parse ⟨1, by simp⟩ (ι := List String) where
- parse := parse
+ parse := pure ∘ parse
instance : Part ⟨1, _⟩ Parts.One (ι := List String) (ρ := Nat) where
run := part1