diff options
author | Robby Zambito <contact@robbyzambito.me> | 2025-05-18 20:32:28 -0400 |
---|---|---|
committer | Robby Zambito <contact@robbyzambito.me> | 2025-05-19 08:17:01 -0400 |
commit | 4c8a16680466752f369ca8765df9bad7e6fd9d83 (patch) | |
tree | 55a817ffe0d6f2e8188fdeb2186a9173fe8ad958 | |
parent | 2a6552fe76df17e76ee77d6d552e33e1fa41fa11 (diff) |
Somehow this is 4ms slower??push-vzlrymwsurqv
-rw-r--r-- | src/main.zig | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/main.zig b/src/main.zig index 496d14f..ee3db43 100644 --- a/src/main.zig +++ b/src/main.zig @@ -2,9 +2,9 @@ const SudokuSolver = struct { const join = std.simd.join; // Each cell exists in memory three times. // This makes it easy to compare a guess against all relevant cells simultaneously. - rows: [9]@Vector(9, u8), - cols: [9]@Vector(9, u8), - boxes: [9]@Vector(9, u8), + rows: [9][9]u8, + cols: [9][9]u8, + boxes: [9][9]u8, fn init(board: [9][9]u8) !SudokuSolver { var res: SudokuSolver = .{ @@ -49,7 +49,7 @@ const SudokuSolver = struct { var most_constrained_moves: ?PossibleMoves = null; for (self.rows, 0..) |r, row| { - for (@as([9]u8, r), 0..) |cell, col| { + for (r, 0..) |cell, col| { if (cell == 0) { const current_possible_moves = self.possibleMovesForCell(row, col); switch (current_possible_moves.count()) { @@ -118,8 +118,7 @@ const SudokuSolver = struct { fn display(self: SudokuSolver, writer: std.io.AnyWriter) !void { for (self.rows, 0..) |row, i| { - // Can't loop over row directly? - for (@as([9]u8, row), 0..) |cell, j| { + for (row, 0..) |cell, j| { try writer.print("{d} ", .{cell}); if (j % 3 == 2 and j < 8) { try writer.print("| ", .{}); |