summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main.zig11
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("| ", .{});