|
Post by (X) on Aug 7, 2023 19:36:09 GMT 1
A fun challenge...
Who can come up with the fastest Sudoku Solver using GFA BASIC 32 for Windows? You can use whatever source: human or machine, to help you. You must submit your source code for others to compile, no external or 'hidden code' GL32 library, .BAT, .COM, .EXE or .DLL. Post your code solution here, preferably with a screen capture and time to solve: (Timer_End - Timer_Beg) expressed in milliseconds. Lets call the procedure: Sudoku_Solver_Calculation() that starts with a partially filled, 9 by 9, Byte typed, base 1, Global array called: Grid().
$Library "gfawinx" $Library "UpdateRT" UpdateRuntime ' Patches GfaWin23.Ocx Option Base 1 Global Grid(1 .. 9, 1 .. 9) As Byte
FullW 1 Sudoku_Solver_Calculations Do : Sleep : Until Me Is Nothing
Procedure Sudoku_Solver_Calculations() Dim t0# = Timer ' ' Calcs ' Trace Timer - t0 EndProc
|
|
|
Post by scalion on Aug 8, 2023 11:15:24 GMT 1
Yes it's a good challenge.
|
|
|
Post by (X) on Aug 9, 2023 15:09:21 GMT 1
Ok. Try to beat this first attempt...
The start state is a diagonal set of numbers from 1 to 9, upper left to lower right.
Attachments:Demo Sudoku Solver.G32 (17.02 KB)
|
|
|
Post by (X) on Aug 9, 2023 18:14:39 GMT 1
This version is setup with a "difficult" puzzle and the original given numbers are in red.
Attachments:Demo Sudoku Solver.G32 (17.64 KB)
|
|
|
Post by scalion on Aug 10, 2023 10:55:18 GMT 1
I make one too
That result is the same :
|
|
|
Post by scalion on Aug 10, 2023 11:16:16 GMT 1
This version is setup with a "difficult" puzzle and the original given numbers are in red.
i have an "array bound execed" in you demo...
|
|
|
Post by (X) on Aug 10, 2023 14:17:41 GMT 1
Verification:
Dim i, j For i = 1 To 9 j = i - 1 trace 1 + 3 * (j \ 3) Next
This should fix the problem...
Local startRow = 1 + 3 * ((row-1) \ 3) Local startCol = 1 + 3 * ((col-1) \ 3)
|
|
|
Post by scalion on Aug 11, 2023 13:25:29 GMT 1
I read this (FR) : www.lemonde.fr/passeurdesciences/article/2012/01/08/17-est-le-nombre-de-dieu-au-sudoku_5986165_5470970.htmlThey said the minimum of indices is 17 for a all sudoku grid combinations. I want to go further in the challenge. Coding a grid reducer to find the minimum of 17 indices ! Who is not affraid ? Good Luck.
To do this, i will make a function to count numbers of solutions for grid, but not great than 2.
If number of solutions is 0 : The indices are false
If number of solutions is 1 : The grid is good to be playable If number is 2 (or more) : Indices missing !
I will product a random grid and I will remove each number one by one and test the number of solutions. There should only be 17 left!
|
|
|
Post by (X) on Aug 11, 2023 13:38:25 GMT 1
En effet, Seldon, eh, scalion... BingGPT répond:
According to BingGPT:
|
|
|
Post by (X) on Aug 11, 2023 13:53:47 GMT 1
Lets start this in another post: "CODE CHALLENGE: Sudoku: Find 17..."
|
|