This site uses different types of cookies, including analytics and functional cookies (its own and from other sites). To change your cookie settings or find out more, click here. If you continue browsing our website, you accept these cookies.
Thanks for taking a look at this John.
@JohnJPS wrote:grabbing "First" in the Summary tool is not reliable
It only uses that "First" when the count of remaining candidate digits is 1, so I think using First should be fine. When the count is > 1, it replaces First with a "0".
The real problem is where none of the "0" cells can be resolved down to a single digit. That then causes the exact same macro output to be fed back into the input, and it loops infinitely.
The only way I can think to get around that is to "guess" an answer and see if the puzzle can be completed from there. If it can't, make a different guess and try again. I was wondering if your R-code does that somehow, but I can't see it.
Yes, you're correct that it's an infinite loop due to it passing in the same value it started with; if it could instead pass in candidate guesses to iterate over, that might he interesting.
I believe the difference in the R code is in the while loop of the sudoku.solve() function. I do not believe the base tools code has that iterative equivalent.
@JohnJPS wrote:I believe the difference in the R code is in the while loop of the sudoku.solve() function. I do not believe the base tools code has that iterative equivalent.
Comparing sudoku.solve() to my iterative macro, the only difference I can see is that if, for all "0" cells it finds, the R code can't find a solution for any of them, it stops iterating. It gives up rather than looping forever. But clearly that's not happening with this puzzle. In some cases, where my macro can't find a solution for a "0" cell, the R code can.
So I think the extra "cleverness" is somewhere in sudoku.square(). I'm not used to reading R code, so I'm struggling to figure out what its doing... I know its not really very important, but its bugging me.
To help me understand what the R code is doing, I am reading the page mentioned at the top of the R-code:
https://www.kaggle.com/dmartin0409/sudoku-solver-in-r
It says:
"2. If step 1 has more than 1 possible value, step through each of these numbers and check the two rows and two columns of the adjacent squares in the 3x3 set. For example, if I'm examining the top left square of a 3x3 set, and I'm trying to see if the number 9 fits in there, look for a 9 in the two columns (middle and right) and the two rows (middle and bottom)."
I think this point #2 is what my macro is missing. Points #1, #3 & #4 correspond to the 3 join tools in my macro. Just need to get my head around it!
I just started doing the weekly challenges yesterday with challenge #201, but spotted also this very intriguing challenge #200 and had to solve it.
I have no idea, whether this is still allowed, but here we go, that's the overview.
For the beginner step a simple parser (and a printer for checking the results) is constructed:
For intermediate/advanced, a solver macro is implemented.
I hope this still counts.
Best,
Johannes
Very nice @PaulRB ... hey @AYXAcademy and @TerryT, based on Paul's research, consider adding the following quiz to the challenge:
000000190230000600000240000000000960000160070048070000001003405009008000006005800
... it defeats some of the posted solutions. Very cool and great job Paul - all I did was borrow from Kaggle; you recreated it with base tools. Nice!
- John
Iterative approach for the advanced, and "CEIL" help for the grid calculation. The assumption is at least one cell can be solved per iteration (i.e. there's a unique value for that cell).
.