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.
Expected is error, because there is more than one valid solution, for example:
If I copied everything correctly, you can see how the rows in the middle band are different.
Hello,
I've got two issues. Timeout and random tests that fail.
Timeout is the fun part. Random tests is the strange part and i need some help.
If I believe the output of the attempt :
My solution is wrong but I have no idea of the expected.
My solver found this solution :
What should be the expected output ?
i cant even describe how i struggled during this f#kin kata, it is almaust destroed my life. few mounths passed i did it, it was terrible but i like this pain. thank you hel yeaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
@Erhu, proving that sudoku has multiple solution may be done in different ways and one of them is not that time-consuming.
Think of what it means that there are several solutions in terms of the resulting elements positions & values.
AFAIU, if you have a sudoku with zero empty (zeroed) cells, which doesn't require to be solved, it should be marked as invalid.
I seem to have a problem where the program asks me to mark a grid that seems valid as invalid, like this one:
I am sure this is simple oversight on my part, as many people have solved this in Python and I don't think that everyone has made a mistake but me. Still, I can't find a reason for why this grid should be invalid. If someone could enlighten me I would be very grateful as I have been working on my solution for a week and would love to finally submit it :).
@akar-0 Thanks for the advice, the difficulty is definitly in the back tracking, but like mentioned, the test results are inconsistent and it makes it hard to debug.
I run my solution 20 times. I got 4 timeouts, and remaining 16 runs had quite comsistent times of 5-8s. So yes, it seems that its possible to get a pessimistic case, but I think the ratio is not terrible, and i also think there is many better solutions than mine.
All katas have random tests (or should have). You give no proof that tests would be buggy. If you have not been able to solve this kata (I have not either) this cannot be considered a kata issue.
Try to practica on easier ones, 2kyu katas are supposed to be hard coding challenge.
The tests are randomly generate, you just have to get lucky and not run into bugged one.
How did others, including me, solved it then?
It could have been a good test but proving sudoku has single solution requires backtracking, which make the job time out, mainly because of the 200 random tests.
your code passes that test ("single solution"). Either that's not the problem you're facing, or you should reset the trainer.
Closing
According to your tests, this grid is invalid:
[1, 0, 0, 0, 0, 0, 4, 7, 0]
[0, 8, 0, 2, 0, 4, 0, 1, 0]
[0, 6, 5, 0, 0, 0, 0, 0, 9]
[0, 0, 0, 0, 0, 1, 0, 9, 0]
[0, 0, 0, 3, 5, 0, 0, 0, 0]
[0, 7, 6, 0, 0, 9, 0, 0, 8]
[2, 0, 0, 5, 0, 0, 7, 4, 0]
[0, 0, 0, 0, 1, 8, 0, 0, 0]
[0, 3, 0, 7, 0, 0, 0, 0, 0]
Edit: OK, scratch that, apparently the problem was caused by another grid, not this one. I updated my solution to deal with those scenarios. Is there a way to delete the previous solution if it turned out to be not 100% correct?
In the "single solutions" list, there is the following problem:
Input
[6, 0, 0, 0, 0, 0, 0, 0, 2]
[0, 0, 3, 6, 0, 1, 7, 0, 0]
[0, 7, 0, 0, 4, 0, 0, 1, 0]
[0, 5, 0, 9, 0, 4, 0, 3, 0]
[0, 0, 9, 0, 0, 0, 1, 0, 0]
[0, 6, 0, 7, 0, 8, 0, 2, 0]
[0, 3, 0, 0, 6, 0, 0, 5, 0]
[0, 0, 5, 3, 0, 9, 4, 0, 0]
[7, 0, 0, 0, 0, 0, 0, 0, 3]
to which my program provides the following output:
Output
[6, 1, 8, 5, 9, 7, 3, 4, 2]
[4, 9, 3, 6, 2, 1, 7, 8, 5]
[5, 7, 2, 8, 4, 3, 9, 1, 6]
[2, 5, 7, 9, 1, 4, 6, 3, 8]
[3, 8, 9, 2, 5, 6, 1, 7, 4]
[1, 6, 4, 7, 3, 8, 5, 2, 9]
[9, 3, 1, 4, 6, 2, 8, 5, 7]
[8, 2, 5, 3, 7, 9, 4, 6, 1]
[7, 4, 6, 1, 8, 5, 2, 9, 3]
And yet... it says the solution is invalid. What is going on?
Loading more items...