Skip to content

Commit

Permalink
Remove workarounds for carbon-language#4716.
Browse files Browse the repository at this point in the history
  • Loading branch information
zygoloid committed Dec 21, 2024
1 parent b9bf78f commit 4c5629d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion examples/advent2024/day4_common.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions examples/advent2024/day4_part1.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions examples/advent2024/day4_part2.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 4c5629d

Please sign in to comment.