Skip to content

Commit

Permalink
nested patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
mdr committed Dec 4, 2024
1 parent de31c5a commit 5c6a656
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
2 changes: 0 additions & 2 deletions Aoc2024/Day04/Parser.lean
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,3 @@ import Aoc2024.Utils
import Std

def parseGrid (s : String) : Grid := s.lines.map (·.toList)

-- #guard parseReports exampleInput == Except.ok 42
9 changes: 4 additions & 5 deletions Aoc2024/Day04/Solve.lean
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,10 @@ private def slidingGrids (grid : Grid): List Grid :=
]

private def is2Mas: Grid -> Bool
| [r1, r2, r3] =>
let match1 := match r1 with | ['M', _, 'S'] => true | _ => false
let match2 := match r2 with | [_, 'A', _] => true | _ => false
let match3 := match r3 with | ['M', _, 'S'] => true | _ => false
match1 && match2 && match3
| [
['M', _, 'S'],
[ _, 'A', _],
['M', _, 'S']] => true
| _ => false

private def rotate90 : Grid -> Grid := flipHorizontal ∘ List.transpose
Expand Down

0 comments on commit 5c6a656

Please sign in to comment.