Ad
  • Default User Avatar

    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?

  • Default User Avatar

    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.

  • Default User Avatar

    My 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")