Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Finally I find the root cause. I use iteration to find the solution. If I write only one iteration function to both return solution and raise errors, the problem above occurs. However, if I write two functions, one is iteration function to find the solution, and another function to validate puzzle, raise errors, call iteration function and return the solution, the problem above will never happen. I am afraid if it is an issue for this Kata?
Thank you for the reply. Yes, you are correct, my code show here only check incorrect number of rows/cols, but other codes not show here check "numbers out of 0-9", "dumplicate numbers", "no solution" and so on. It should not fail 9 out of 10 Invalid grids tests with these codes which run normally on my own Python IDE.
read this line from description carefully
does your
if
check for all of this? I don't think soMy code (Python) have checked invalid puzzles and raised errors, something just like below. It throws correct RuntimeErrors on my own Python IDE(3.7.3), but fails Invalid grids test with red info "Invalid grid should raise an error.". Would some experts tell me what is the right way to raise errors for this Kata?
if len([y for x in puzzle for y in x]) != 81: raise RuntimeError("Invalid grid: row/col numbers")