Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
mdr committed Dec 1, 2024
1 parent bc974a6 commit 7812a33
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions Aoc2024/Day01/Parser.lean
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import Aoc2024.Utils
import Std
open Std.Internal.Parsec.String
open Std.Internal.Parsec

def splitOnWhitespace (s : String) : List String :=
s.split Char.isWhitespace |> .filter (· ≠ "")
Expand All @@ -16,3 +19,13 @@ def parseTwoNumbers (line : String) : Except String (Int × Int) := do

def parseLines (s : String) : Except String (List (Int × Int)) :=
s.splitOn "\n" |>.mapM parseTwoNumbers

def lineParser : Parser (Int × Int) := do
let a ← String.digits
let _ <- String.ws
let b ← String.digits
pure (a, b)

-- def inputParser : Parser (List (Int × Int)) := do
-- let lines ← lineParser.many1
-- pure lines
2 changes: 1 addition & 1 deletion lean-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
leanprover/lean4:stable
leanprover/lean4:v4.13.0

0 comments on commit 7812a33

Please sign in to comment.