Skip to content

Commit 9033825

Browse files
committed
day10 template
1 parent e6619e8 commit 9033825

File tree

7 files changed

+54
-0
lines changed

7 files changed

+54
-0
lines changed

Aoc2024/Day10/Examples.lean

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
def exampleInput :=
2+
"..."

Aoc2024/Day10/Main.lean

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import Aoc2024.Day10.Solve
2+
import Aoc2024.CustomMonadLift
3+
4+
def main : IO Unit := do
5+
IO.println "Day 10"
6+
IO.println ""
7+
IO.println "Part 1"
8+
let exampleInput <- IO.FS.readFile "Aoc2024/Day10/inputs/example.txt"
9+
let puzzleInput <- IO.FS.readFile "Aoc2024/Day10/inputs/input.txt"
10+
IO.println s!"Example: {<- parseAndSolvePart1 exampleInput}"
11+
let answerPart1 <- parseAndSolvePart1 puzzleInput
12+
IO.println s!"Puzzle: {answerPart1}"
13+
assert! (answerPart1 == -1)
14+
IO.println ""
15+
IO.println "Part 2"
16+
IO.println s!"Example: {<- parseAndSolvePart2 exampleInput}"
17+
let answerPart2 <- parseAndSolvePart2 puzzleInput
18+
IO.println s!"Puzzle: {answerPart2}"
19+
assert! (answerPart2 == -1)

Aoc2024/Day10/Parser.lean

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import Aoc2024.Day10.Examples
2+
import Aoc2024.Day10.Types
3+
import Aoc2024.Utils
4+
import Std
5+
open Std.Internal.Parsec.String
6+
open Std.Internal.Parsec
7+
8+
private def inputParser : Parser (List Int) := sorry
9+
10+
def parseInput : String -> Except String (List Int) := inputParser.run
11+
12+
-- #guard parseInput exampleInput == Except.ok 42

Aoc2024/Day10/Solve.lean

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import Aoc2024.Utils
2+
import Aoc2024.Day10.Examples
3+
import Aoc2024.Day10.Parser
4+
import Aoc2024.Day10.Types
5+
6+
-- Part 1
7+
8+
private def solvePart1 (input : List Int) : Int := sorry
9+
10+
def parseAndSolvePart1 (s : String): Except String Int := parseInput s |>.map solvePart1
11+
12+
-- #guard parseAndSolvePart1 exampleInput == Except.ok -1
13+
14+
-- Part 2
15+
16+
private def solvePart2 (input : List Int) : Int := sorry
17+
18+
def parseAndSolvePart2 (s : String): Except String Int := parseInput s |>.map solvePart2
19+
20+
-- #guard parseAndSolvePart2 exampleInput == Except.ok -1

Aoc2024/Day10/Types.lean

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import Aoc2024.Utils

Aoc2024/Day10/inputs/example.txt

Whitespace-only changes.

Aoc2024/Day10/inputs/input.txt

Whitespace-only changes.

0 commit comments

Comments
 (0)