A quick and dirty Sudoku solver, may or may not work.

Not sure if there any use-case for such a tool on PICO-8, but here it is.

⚠️ Looking a the source code may or may not induce permanent blindness ⚠️

## Controls :

⬆️⬇️⬅️➡️ : move the cursor.

❎ : select a cell/value.

[1️-9️] : fill cell with the corresponding digit if possible.

Pause : access menu.

## changelog

2022-11-06:

- added a
*solve cell*option.

Hi @choo-t. Superb work here to solving Sudoku.

My Godfather absolutely loves this puzzle and plays it on the daily.

One problem I am seeing and correct me if I'm wrong - there is more than one solution for some Sudoku puzzles.

Where there only one solution this might be invaluable to helping someone solve a Sudoku puzzle they are having difficulty with.

Failing that, not.

@dw817 There was actually a whole argument on the PICO-8 discord about uniqueness of solution for Sudoku.

I shared your view about multiple solution at first, but turn out I was wrong and the Sudoku community is quite picky about this rule : a proper Sudoku should have only one solution ¹².

Hi @choo-t.

Actually I hadn't considered. The person who would use this cart will be one who cannot solve a Sudoku puzzle they are working on. They would fill in every piece they know and expect the program to solve the rest for them.

So, yeah, actually, this program is very good for that. I can see that now - provided they are not trying to compare the solution here with one that is recorded later in the testing material.

For that alone, gold star to hang on your mantle. :)

One more thing, @choo-t. You might add a few options to solve.

- Solve this cel only.
- Solve this square.
- Solve this horizontal line (row).
- Solve this vertical line (column).

In addition to your already available.

- Solve the puzzle.

So your tool becomes then a great assist for Sudoku players without forcing them to solve the whole puzzle if they just want a bit of help.

If you are not already doing so, I would have a total solve each time the person inputs a number, then when they want a row, column, block, or cel solved, you just pull it from the already hidden and solved array.

@dw817

As requested, I added a *solve cell* option.

The others can't really be nicely implemented with the actual codebase and (lackluster) UX, as presently, any cell displayed on the edit phase are treated as locked cell, and thus, remove entropy from cells on the same row/column/block, so solving a whole line will cascade and solve even more cells, themselves solving more cells etc.

Hi @choo-t.

Excellent for solving cell !

Yet I think you can easily do the columns and rows - this way. Do a total SOLVE each time a number is entered. But don't show the results. Keep that in a secret array, ready to use.

When they want to see the full answer, merely transfer the secret array to visual. Nothing more.

If they want a row or column. No need for complex calculations or anything, merely transfer from the secret array that very specific row or column. Nothing more.

No further calculations need to be done once you do an entire solve and have saved those results to your secret array.

[Please log in to post a comment]