Log In  

Cart #sudoku_solver-1 | 2022-11-06 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA

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.



  • added a solve cell option.
P#120113 2022-11-04 14:21 ( Edited 2022-11-06 21:39)

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.

P#120133 2022-11-04 23:53

@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 ¹².

P#120138 2022-11-05 01:04 ( Edited 2022-11-05 01:05)

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. :)

P#120140 2022-11-05 01:24

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

  1. Solve this cel only.
  2. Solve this square.
  3. Solve this horizontal line (row).
  4. Solve this vertical line (column).

In addition to your already available.

  1. 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.

P#120156 2022-11-05 17:25

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.

P#120230 2022-11-06 21:54

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.

P#120231 2022-11-06 22:02

[Please log in to post a comment]