Skip to content

Commit 1ac900d

Browse files
committed
Refactor part 1
1 parent 06187f1 commit 1ac900d

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

src/day4.gleam

+6-12
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,13 @@ const xmas = "XMAS"
4141

4242
fn is_xmas(grid: parse.Grid, at: #(Int, Int), dir: Dir, index: Int) -> Bool {
4343
let letter = string.slice(xmas, index, 1)
44-
case dict.get(grid, at) {
45-
Ok(value) -> {
46-
case value == letter {
47-
True -> {
48-
case index {
49-
3 -> True
50-
_ -> is_xmas(grid, next_cell(at, dir), dir, index + 1)
51-
}
52-
}
53-
False -> False
44+
case get_at(grid, at) == letter {
45+
True ->
46+
case index {
47+
3 -> True
48+
_ -> is_xmas(grid, next_cell(at, dir), dir, index + 1)
5449
}
55-
}
56-
Error(_) -> False
50+
False -> False
5751
}
5852
}
5953

0 commit comments

Comments
 (0)