# Weekly Challenge

Solve the challenge, share your solution and summit the ranks of our Community!
###### IDEAS WANTED

We're actively looking for ideas on how to improve Weekly Challenges and would love to hear what you think!

Submit Feedback
We've recently made an accessibility improvement to the community and therefore posts without any content are no longer allowed. Please use the spoiler feature or add a short message in the message body in order to submit your weekly challenge.

## Challenge #200: Sudoku Solver

Highlighted
8 - Asteroid

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.

Highlighted
15 - Aurora

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.

Highlighted
8 - Asteroid

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

Highlighted
8 - Asteroid

To help me understand what the R code is doing, I am reading the page mentioned at the top of the R-code:

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!

Highlighted
5 - Atom

This was my first challenge!  Will work on trying to solve the Intermediate next...

Beginner:

Spoiler
Highlighted
Alteryx Certified Partner

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:

Spoiler

For intermediate/advanced, a solver macro is implemented.

Spoiler

I hope this still counts.

Best,

Johannes

Highlighted
8 - Asteroid

I got there in the end! Previously unsolvable puzzle now solved.

Spoiler

Highlighted
15 - Aurora

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

Highlighted
Alteryx Partner

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

Spoiler
Main WorkflowIterativeGrid Calculation

.

Highlighted
6 - Meteoroid

my solution for beginner level:

Spoiler