Skip to content

Commit

Permalink
day10 template
Browse files Browse the repository at this point in the history
  • Loading branch information
mdr committed Dec 9, 2024
1 parent e6619e8 commit 9033825
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Aoc2024/Day10/Examples.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def exampleInput :=
"..."
19 changes: 19 additions & 0 deletions Aoc2024/Day10/Main.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import Aoc2024.Day10.Solve
import Aoc2024.CustomMonadLift

def main : IO Unit := do
IO.println "Day 10"
IO.println ""
IO.println "Part 1"
let exampleInput <- IO.FS.readFile "Aoc2024/Day10/inputs/example.txt"
let puzzleInput <- IO.FS.readFile "Aoc2024/Day10/inputs/input.txt"
IO.println s!"Example: {<- parseAndSolvePart1 exampleInput}"
let answerPart1 <- parseAndSolvePart1 puzzleInput
IO.println s!"Puzzle: {answerPart1}"
assert! (answerPart1 == -1)
IO.println ""
IO.println "Part 2"
IO.println s!"Example: {<- parseAndSolvePart2 exampleInput}"
let answerPart2 <- parseAndSolvePart2 puzzleInput
IO.println s!"Puzzle: {answerPart2}"
assert! (answerPart2 == -1)
12 changes: 12 additions & 0 deletions Aoc2024/Day10/Parser.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import Aoc2024.Day10.Examples
import Aoc2024.Day10.Types
import Aoc2024.Utils
import Std
open Std.Internal.Parsec.String
open Std.Internal.Parsec

private def inputParser : Parser (List Int) := sorry

def parseInput : String -> Except String (List Int) := inputParser.run

-- #guard parseInput exampleInput == Except.ok 42
20 changes: 20 additions & 0 deletions Aoc2024/Day10/Solve.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import Aoc2024.Utils
import Aoc2024.Day10.Examples
import Aoc2024.Day10.Parser
import Aoc2024.Day10.Types

-- Part 1

private def solvePart1 (input : List Int) : Int := sorry

def parseAndSolvePart1 (s : String): Except String Int := parseInput s |>.map solvePart1

-- #guard parseAndSolvePart1 exampleInput == Except.ok -1

-- Part 2

private def solvePart2 (input : List Int) : Int := sorry

def parseAndSolvePart2 (s : String): Except String Int := parseInput s |>.map solvePart2

-- #guard parseAndSolvePart2 exampleInput == Except.ok -1
1 change: 1 addition & 0 deletions Aoc2024/Day10/Types.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import Aoc2024.Utils
Empty file.
Empty file added Aoc2024/Day10/inputs/input.txt
Empty file.

0 comments on commit 9033825

Please sign in to comment.