Skip to content

Commit 5c6a656

Browse files
committed
nested patterns
1 parent de31c5a commit 5c6a656

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

Aoc2024/Day04/Parser.lean

-2
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,3 @@ import Aoc2024.Utils
44
import Std
55

66
def parseGrid (s : String) : Grid := s.lines.map (·.toList)
7-
8-
-- #guard parseReports exampleInput == Except.ok 42

Aoc2024/Day04/Solve.lean

+4-5
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,10 @@ private def slidingGrids (grid : Grid): List Grid :=
5454
]
5555

5656
private def is2Mas: Grid -> Bool
57-
| [r1, r2, r3] =>
58-
let match1 := match r1 with | ['M', _, 'S'] => true | _ => false
59-
let match2 := match r2 with | [_, 'A', _] => true | _ => false
60-
let match3 := match r3 with | ['M', _, 'S'] => true | _ => false
61-
match1 && match2 && match3
57+
| [
58+
['M', _, 'S'],
59+
[ _, 'A', _],
60+
['M', _, 'S']] => true
6261
| _ => false
6362

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

0 commit comments

Comments
 (0)