UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Sudoku Hint?    
 
   
doctor9
post Aug 23 2017, 10:07 AM
Post#1


UtterAccess Editor
Posts: 17,902
Joined: 29-March 05
From: Wisconsin


So, I like to do the 5-star USA Today Sudoku puzzle to relax. I've created a database form that lets me input the known numbers, and with a click of a button, it will find ONE new digit and explain how it determined that number. In other words, it provides hints, and shows you how you could have found it yourself.

Unfortunately, the puzzle from 8/11/17 is a doozy - I can only find 42 of the 81 digits. At that point, my little hint form and I are stuck.

If you know of a utility that can find a new digit AND explain how it found that digit, let me know. Or, if you're really good at solving Sudoku puzzles, take a look at the one in the form (it includes several test puzzles, the USA Today one is the last puzzle). Just click the Solve button a few times until it gives up. At that point, if you can get further than the form, and you can describe how you did it (without guessing), please let me know.

Dennis
Attached File(s)
Attached File  Sudo.zip ( 96.21K )Number of downloads: 9
 

--------------------
(;,;) Li'l Cthulu says: Please talk about what you're trying to do, as well as how you're doing it.
Changing your real table name to "Table1" and your real form name to "Form1" in your posts makes it more difficult to understand what's going on, not easier.
Guidelines for Posting Questions
Go to the top of the page
 
RAZMaddaz
post Aug 23 2017, 10:19 AM
Post#2


UtterAccess VIP
Posts: 9,522
Joined: 23-May 05
From: Bethesda, MD USA


Doc,

Can I make a suggestion.....

Might you be able to add two horizontal and vertical lines, similar to a Tic-Tac-Toe board? This can help the Player see things easier.

RAZMaddaz
Go to the top of the page
 
doctor9
post Aug 23 2017, 10:22 AM
Post#3


UtterAccess Editor
Posts: 17,902
Joined: 29-March 05
From: Wisconsin


RAZ,

I just used the Etched border to show the tic-tac-toe divisions. It's probably too subtle, I agree. But that sort of thing is super easy for people if they want to customize it. Really, what I'm looking for is advice on how to improve the VBA, not the look and feel.

Dennis

--------------------
(;,;) Li'l Cthulu says: Please talk about what you're trying to do, as well as how you're doing it.
Changing your real table name to "Table1" and your real form name to "Form1" in your posts makes it more difficult to understand what's going on, not easier.
Guidelines for Posting Questions
Go to the top of the page
 
RAZMaddaz
post Aug 23 2017, 11:26 AM
Post#4


UtterAccess VIP
Posts: 9,522
Joined: 23-May 05
From: Bethesda, MD USA


Well, I can't do this is in VBA, as you know, but the bottom right is a 3, left of the seven.

After I found that, everything else seems easy!

RAZMaddaz
Go to the top of the page
 
doctor9
post Aug 23 2017, 12:31 PM
Post#5


UtterAccess Editor
Posts: 17,902
Joined: 29-March 05
From: Wisconsin


RAZ,

Yes, the solver can find up to 42 of the digits, including that one. If you click the Solve button a few times until it can't find more, you can see how far it gets. If you can find a digit AFTER you've done that, please let me know.

Dennis

--------------------
(;,;) Li'l Cthulu says: Please talk about what you're trying to do, as well as how you're doing it.
Changing your real table name to "Table1" and your real form name to "Form1" in your posts makes it more difficult to understand what's going on, not easier.
Guidelines for Posting Questions
Go to the top of the page
 
theDBguy
post Aug 23 2017, 01:20 PM
Post#6


Access Wiki and Forums Moderator
Posts: 71,196
Joined: 19-June 07
From: SunnySandyEggo


Hi Dennis,

Out of curiosity, I opened your program and went to the last puzzle. Then, I clicked on the "hint" button 12 times (until the program can't find any more new digits). However, looking at the image below, I think the value should be a 4 because the right side shows only one possible location for it in the same row.

Attached File  sudoku.png ( 23.46K )Number of downloads: 0


Am I correct?

Hope it helps...

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Microsoft Access MVP | Access Website | Access Blog | Email
Go to the top of the page
 
doctor9
post Aug 23 2017, 01:27 PM
Post#7


UtterAccess Editor
Posts: 17,902
Joined: 29-March 05
From: Wisconsin


DB,

Yeah, that sure looks like something I need to look at. UniqueRowValue should be catching that.

Thanks!

Dennis

EDIT: Yeah, something's going wrong - numbers are being ADDED to that array, which should never happen. Need to track down where that's happening, and fix it.

--------------------
(;,;) Li'l Cthulu says: Please talk about what you're trying to do, as well as how you're doing it.
Changing your real table name to "Table1" and your real form name to "Form1" in your posts makes it more difficult to understand what's going on, not easier.
Guidelines for Posting Questions
Go to the top of the page
 
theDBguy
post Aug 23 2017, 01:27 PM
Post#8


Access Wiki and Forums Moderator
Posts: 71,196
Joined: 19-June 07
From: SunnySandyEggo


I think here's the final solution (I didn't see a button to verify the solution).

Attached File  solution.png ( 22.46K )Number of downloads: 1


I hope it's correct.

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Microsoft Access MVP | Access Website | Access Blog | Email
Go to the top of the page
 
doctor9
post Aug 23 2017, 01:39 PM
Post#9


UtterAccess Editor
Posts: 17,902
Joined: 29-March 05
From: Wisconsin


DB,

There's no 4 in column 2, but there are two 5's.

I should probably write a simple verification subroutine as well.

So here's the deal: When you click Solve or Hint, it resets the array (puts 123456789 in each box). Then, it looks at the data entry boxes and removes the other possibilities from the corresponding array box. So, if you have 9 in the upper left corner data entry box, then the array's upper left box goes from 123456789 to just 9. THEN it goes through each strategy once. It looks like I need to run the strategies at least twice, so there's no reset, because after strategy 5 makes it possible for strategy 4 to find a new digit, there's no way for strategy 4 to do so because of the reset.

It only seems to find that one 4 in column 1, but the idea of multiple runs without a reset seems to have some validity at least.

Thanks, that was very helpful!

Dennis

--------------------
(;,;) Li'l Cthulu says: Please talk about what you're trying to do, as well as how you're doing it.
Changing your real table name to "Table1" and your real form name to "Form1" in your posts makes it more difficult to understand what's going on, not easier.
Guidelines for Posting Questions
Go to the top of the page
 
mklein
post Aug 23 2017, 01:44 PM
Post#10



Posts: 264
Joined: 7-August 12
From: BC, Canada


That's a hard puzzle. I wrote a sudoku solver that speculates if there is not a certain solution, and then rolls back its speculations if it gets stuck, and this is the hardest puzzle it has ever solved. This took 66 iterations, so a considerable number of trials and rollbacks. The next hardest puzzle I have takes 34 iterations.
But the next move is a 2 at row7 col6 (cell76). To confirm, there is an 8 to the left of the new 2, and a 7 above it.

DBGuy, you have a 5 at (1,3) and a 5 at (3,2)

--------------------
| Mark Klein | Access 2010 | Windows 10 | Visual Studio 2013
Go to the top of the page
 
theDBguy
post Aug 23 2017, 01:50 PM
Post#11


Access Wiki and Forums Moderator
Posts: 71,196
Joined: 19-June 07
From: SunnySandyEggo


Oops, like I said, I didn't verify it and was hoping there's a "verify" button instead.

Or, how about an immediate warning if the user enters an invalid number?

Just a thought...

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Microsoft Access MVP | Access Website | Access Blog | Email
Go to the top of the page
 
mklein
post Aug 23 2017, 01:52 PM
Post#12



Posts: 264
Joined: 7-August 12
From: BC, Canada


Problem is you don't know it's invalid until you solve further and get stuck. Then you have to roll back.
Mark

--------------------
| Mark Klein | Access 2010 | Windows 10 | Visual Studio 2013
Go to the top of the page
 
zocker
post Aug 23 2017, 02:07 PM
Post#13


Utterly Eccentric and Moderator
Posts: 4,055
Joined: 4-March 00
From: Bristol / Ipswich / Spain


Dennis, that's a wonderful piece of work-genius I think. I can't solve Soduko or any of its relatives, I did try when laid up in hospital some years ago but achieved no success. I did wonder then if there were a computer solution- it does seem the sort of problem which should. I think that there may be a (horribly complex) SQL solution to this, after all we are dealing with sets and numbers which are IN and are NOT in specified sets.....my mind isn't up to it tho!

More power to you!



Zocker

James

--------------------
I would like to remind members and visitors that UtterAccess is a NON SMOKING website. In that respect, it is the worlds first Thank you for not smoking.
Go to the top of the page
 
mklein
post Aug 23 2017, 02:08 PM
Post#14



Posts: 264
Joined: 7-August 12
From: BC, Canada


...and then a 2 at cell88.

--------------------
| Mark Klein | Access 2010 | Windows 10 | Visual Studio 2013
Go to the top of the page
 
doctor9
post Aug 23 2017, 02:26 PM
Post#15


UtterAccess Editor
Posts: 17,902
Joined: 29-March 05
From: Wisconsin


James,

Basically, I did what I usually do; I figure out how I do something manually, then write code to emulate that action. So, if I scan across a row to see if a 2 only fits in two cells within one 3x3 grid, I know the 2 can ONLY be in one of those two cells. In the real world, I mark those two squares with a special mark that means "2". With VBA, I remove the "2" from the other cells in that 3x3 grid, and the rest of that row.

This update now runs each strategy twice before checking to see if it found any new digits, instead of once. That finds the "4" that theDBGuy spotted, but sadly it doesn't solve any further.

If you place a 1 in column 2 next to the given 3 in column 1, that's enough to allow the code to solve the rest. However, the placement of that 1 is not based on elimination, it's a guess (it can either be 1 or 4, so it's a 50-50 chance). I assumed that the USA Today puzzles did not require guessing, which is why I like them. However, I'm still stuck on this one. If anyone can get further than my form does (again, without guesswork), please let me know which digit you figured out, and how.

Meanwhile, here's the updated v1.1 file... which also now includes a "Validate" button to make sure you don't have any duplicate digits. It's not perfect, but it's better than nothing.

Dennis

EDIT: Minor bug fix to the previous version of the attachment
Attached File(s)
Attached File  Sudo11.zip ( 127.13K )Number of downloads: 0
 

--------------------
(;,;) Li'l Cthulu says: Please talk about what you're trying to do, as well as how you're doing it.
Changing your real table name to "Table1" and your real form name to "Form1" in your posts makes it more difficult to understand what's going on, not easier.
Guidelines for Posting Questions
Go to the top of the page
 
doctor9
post Aug 23 2017, 02:30 PM
Post#16


UtterAccess Editor
Posts: 17,902
Joined: 29-March 05
From: Wisconsin


Mark,

> Problem is you don't know it's invalid until you solve further and get stuck. Then you have to roll back.

Exactly why I hate Sudoku puzzles that require guesswork. smile.gif

By the way, did you take a look at the diabolical examples in my file? I forget where I found them, but I wanted to include them if only to test my code's ability to solve the puzzles while I was developing it.

Dennis

EDIT: You say you wrote one that does guessing and rollbacks? You should take a look at my code strategies and maybe incorporate them into yours. For example, the cells at row 5, columns 2 and 3 are narrowed down to either 1 or 4. In other words, that row starts with either 314 or 341, with no other possibililties. If you enter a 4 in column 2, you'd get an invalid puzzle. But if you enter a 1, it's solveable from that point. Just two maximum guesses to solve the whole puzzle.

Any chance you could share your code?

Dennis

--------------------
(;,;) Li'l Cthulu says: Please talk about what you're trying to do, as well as how you're doing it.
Changing your real table name to "Table1" and your real form name to "Form1" in your posts makes it more difficult to understand what's going on, not easier.
Guidelines for Posting Questions
Go to the top of the page
 
the_captain_slog
post Aug 23 2017, 04:46 PM
Post#17



Posts: 1,036
Joined: 1-July 09
From: England - UK A small island north of France


i tried to do this in excel

have code that will solve an easy puzzle

starts with removing all numbers entered
then removes all numbers entered in rows, columns and squares
if single numbers left it enters these into master grid and starts over again
checks for single numbers in a row, column or square e.g. 1 3 & 5 could fit in 4 squares but 1, 3 , 5 and 9 are in the other it fills that cell with 9

recursive till it solves puzzle or no changes made in a complete cycle


also checks for where 2 numbers will only fit in 2 squares and removes these numbers from other rows, columns, squares where appropriate

as stated b4 it solves simple sudoku - work in progress to solve harder puzzles

defining the logic - i use to manually solve these - into a VBA sub is the bit i enjoy - frustratingly sometimes

like your access version Dr9

--------------------
I am no wizard but I can spell - Sum Thymes

All the knowledge in the world is of no use to fools :- Eagles
Go to the top of the page
 
mklein
post Aug 23 2017, 05:24 PM
Post#18



Posts: 264
Joined: 7-August 12
From: BC, Canada


Dennis, are you sure these diabolical puzzles have solutions? My speculative algorithm seems to try every open node with every possible value, and then crashes when it runs out of possibilities.

I would totally post this code but it's user hostile right now, and it relies on a library for some housekeeping features, so let me tidy it up a little. I wrote it in 2006 and it's totally OOP. The cSudoku class raises a Solve event in a loop, which each cNode class then handles and tries to find its own solution, and so on...

More later,

--------------------
| Mark Klein | Access 2010 | Windows 10 | Visual Studio 2013
Go to the top of the page
 
doctor9
post Aug 24 2017, 08:12 AM
Post#19


UtterAccess Editor
Posts: 17,902
Joined: 29-March 05
From: Wisconsin


mklein,

> are you sure these diabolical puzzles have solutions?

When I was doing my basic research on Sudoku strategies, I came across the ones you see in the database. I just Googled the Easter Monster, and found several pages referring to it, including a forum discussion talking about their solution path. I -assume- the others also have solutions.

Also found the solution for tarek071223170000-052.

Dennis

--------------------
(;,;) Li'l Cthulu says: Please talk about what you're trying to do, as well as how you're doing it.
Changing your real table name to "Table1" and your real form name to "Form1" in your posts makes it more difficult to understand what's going on, not easier.
Guidelines for Posting Questions
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    10th December 2017 - 09:25 PM