From 4d51a4024a86c7aced026fc51de2b362eb1f4068 Mon Sep 17 00:00:00 2001 From: Matt Russell Date: Wed, 4 Dec 2024 08:29:51 +0000 Subject: [PATCH] tidy --- Aoc2024/Day04/Main.lean | 2 +- Aoc2024/Day04/Solve.lean | 16 ++-------------- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/Aoc2024/Day04/Main.lean b/Aoc2024/Day04/Main.lean index 2878efd..b2deb73 100644 --- a/Aoc2024/Day04/Main.lean +++ b/Aoc2024/Day04/Main.lean @@ -8,7 +8,7 @@ def main : IO Unit := do let exampleInput <- IO.FS.readFile "Aoc2024/Day04/inputs/example.txt" let puzzleInput <- IO.FS.readFile "Aoc2024/Day04/inputs/input.txt" IO.println s!"Example: {solvePart1 exampleInput}" - IO.println s!"Puzzle: {solvePart1 puzzleInput}" -- + IO.println s!"Puzzle: {solvePart1 puzzleInput}" -- 2524 IO.println "" IO.println "Part 2" IO.println s!"Example: {solvePart2 exampleInput}" diff --git a/Aoc2024/Day04/Solve.lean b/Aoc2024/Day04/Solve.lean index 2aa7070..c33ffbf 100644 --- a/Aoc2024/Day04/Solve.lean +++ b/Aoc2024/Day04/Solve.lean @@ -47,21 +47,11 @@ private def allGridTransformations : List (Grid -> Grid) := [ List.transpose, flipHorizontal ∘ List.transpose, diagonals, - diagonals ∘ List.transpose, diagonals ∘ flipHorizontal, + diagonals ∘ List.transpose, diagonals ∘ List.transpose ∘ flipHorizontal, ] --- def g := parseGrid exampleInput1 --- #eval g |> id --- #eval g |> flipHorizontal --- #eval g |> List.transpose --- #eval g |> List.transpose |> flipHorizontal --- #eval g |> diagonals --- #eval g |> List.transpose |> diagonals --- #eval g |> flipHorizontal |> diagonals --- #eval g |> flipHorizontal |> List.transpose |> diagonals - def solvePart1 (s : String): Int := let grid := parseGrid s allGridTransformations.sumBy (λ transformation => transformation grid |> countXmasOccurrencesInRows) @@ -71,6 +61,4 @@ def solvePart1 (s : String): Int := def solvePart2 (things : s) : Int := sorry --- def parseAndSolvePart2 (s : String): Except String Int := parseGrid s |>.map solvePart2 - --- #guard parseAndSolvePart2 exampleInput == Except.ok 4 +-- #guard solvePart2 exampleInput2 = 9