diff --git a/examples/advent2024/day4_common.carbon b/examples/advent2024/day4_common.carbon index 40dee6279046..3911882cea1e 100644 --- a/examples/advent2024/day4_common.carbon +++ b/examples/advent2024/day4_common.carbon @@ -26,7 +26,7 @@ class Wordsearch { } fn At[self: Self](x: i32, y: i32) -> i32 { - return if x < 0 or x >= 140 or y < 0 or y >= 140 then -(1 as i32) else self.grid[x][y]; + return if x < 0 or x >= 140 or y < 0 or y >= 140 then -1 else self.grid[x][y]; } // TODO: Make this generic in the length of the search query. diff --git a/examples/advent2024/day4_part1.carbon b/examples/advent2024/day4_part1.carbon index c530e368c7be..15642e30e35e 100644 --- a/examples/advent2024/day4_part1.carbon +++ b/examples/advent2024/day4_part1.carbon @@ -17,9 +17,9 @@ fn Run() { while (y < 140) { var x: i32 = 0; while (x < 140) { - var dy: i32 = -(1 as i32); + var dy: i32 = -1; while (dy <= 1) { - var dx: i32 = -(1 as i32); + var dx: i32 = -1; while (dx <= 1) { if (search.Check4(xmas, x, y, dx, dy)) { ++found; diff --git a/examples/advent2024/day4_part2.carbon b/examples/advent2024/day4_part2.carbon index 18cb509f7453..94fc8b8837a5 100644 --- a/examples/advent2024/day4_part2.carbon +++ b/examples/advent2024/day4_part2.carbon @@ -18,9 +18,9 @@ fn Run() { var x: i32 = 1; while (x < 139) { if ((search.Check3(mas, x - 1, y - 1, 1, 1) or - search.Check3(mas, x + 1, y + 1, -(1 as i32), -(1 as i32))) and - (search.Check3(mas, x - 1, y + 1, 1, -(1 as i32)) or - search.Check3(mas, x + 1, y - 1, -(1 as i32), 1))) { + search.Check3(mas, x + 1, y + 1, -1, -1)) and + (search.Check3(mas, x - 1, y + 1, 1, -1) or + search.Check3(mas, x + 1, y - 1, -1, 1))) { ++found; } ++x;