Ad
  • Custom User Avatar

    Expected is error, because there is more than one valid solution, for example:

    |328|756|491|   |328|756|491|
    |416|239|785|   |416|239|785|
    |795|418|263|   |795|418|263|
    +---+---+---+   +---+---+---+
    |983|542|176|   |983|547|126|
    |564|197|328|   |564|192|378|
    |172|683|954|   |172|683|954|
    +---+---+---+   +---+---+---+
    |649|375|812|   |649|375|812|
    |851|924|637|   |851|924|637|
    |237|861|549|   |237|861|549|
    

    If I copied everything correctly, you can see how the rows in the middle band are different.

  • Custom User Avatar

    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 :

    Input:
    [3, 0, 0, 0, 0, 6, 0, 0, 0]
    [4, 1, 0, 0, 0, 0, 7, 8, 5]
    [7, 0, 0, 0, 0, 0, 0, 0, 0]
    [9, 8, 0, 5, 4, 0, 0, 0, 0]
    [0, 0, 0, 0, 0, 0, 0, 0, 0]
    [0, 0, 0, 0, 8, 3, 0, 5, 4]
    [0, 0, 0, 0, 0, 0, 0, 0, 2]
    [8, 5, 1, 0, 0, 0, 0, 3, 7]
    [0, 0, 0, 8, 0, 0, 0, 0, 9]
    Value is not what was expected
    

    My solution is wrong but I have no idea of the expected.

    My solver found this solution :

    [
      [ 3,9,8,7,5,6,4,2,1 ]
      [ 4,1,6,3,2,9,7,8,5 ]
      [ 7,2,5,4,1,8,9,6,3 ]
      [ 9,8,3,5,4,2,1,7,6 ]
      [ 5,4,2,6,7,1,3,9,8 ]
      [ 1,6,7,9,8,3,2,5,4 ]
      [ 6,7,9,1,3,5,8,4,2 ]
      [ 8,5,1,2,9,4,6,3,7 ]
      [ 2,3,4,8,6,7,5,1,9 ]
    ]
    

    What should be the expected output ?

  • Default User Avatar

    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

  • Custom User Avatar

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

  • Custom User Avatar

    AFAIU, if you have a sudoku with zero empty (zeroed) cells, which doesn't require to be solved, it should be marked as invalid.

  • Default User Avatar

    I seem to have a problem where the program asks me to mark a grid that seems valid as invalid, like this one:

    Input:
    [4, 8, 3, 5, 7, 1, 9, 2, 6]
    [2, 7, 9, 4, 8, 6, 3, 5, 1]
    [5, 1, 6, 9, 2, 3, 8, 7, 4]
    [1, 9, 4, 3, 6, 7, 5, 8, 2]
    [3, 6, 7, 2, 5, 8, 1, 4, 9]
    [8, 2, 5, 1, 9, 4, 7, 6, 3]
    [6, 5, 1, 7, 4, 9, 2, 3, 8]
    [9, 4, 2, 8, 3, 5, 6, 1, 7]
    [7, 3, 8, 6, 1, 2, 4, 9, 5]
    --------------------------
    [[4, 8, 3, 5, 7, 1, 9, 2, 6], [2, 7, 9, 4, 8, 6, 3, 5, 1], [5, 1, 6, 9, 2, 3, 8, 7, 4], [1, 9, 4, 3, 6, 7, 5, 8, 2], [3, 6, 7, 2, 5, 8, 1, 4, 9], [8, 2, 5, 1, 9, 4, 7, 6, 3], [6, 5, 1, 7, 4, 9, 2, 3, 8], [9, 4, 2, 8, 3, 5, 6, 1, 7], [7, 3, 8, 6, 1, 2, 4, 9, 5]]
    [[4, 8, 3, 5, 7, 1, 9, 2, 6], [2, 7, 9, 4, 8, 6, 3, 5, 1], [5, 1, 6, 9, 2, 3, 8, 7, 4], [1, 9, 4, 3, 6, 7, 5, 8, 2], [3, 6, 7, 2, 5, 8, 1, 4, 9], [8, 2, 5, 1, 9, 4, 7, 6, 3], [6, 5, 1, 7, 4, 9, 2, 3, 8], [9, 4, 2, 8, 3, 5, 6, 1, 7], [7, 3, 8, 6, 1, 2, 4, 9, 5]]
    there are 1 solutions
    

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

  • Custom User Avatar

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

  • Custom User Avatar

    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.

  • Custom User Avatar

    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.

  • Custom User Avatar

    The tests are randomly generate, you just have to get lucky and not run into bugged one.

  • Custom User Avatar

    How did others, including me, solved it then?

  • Custom User Avatar

    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.

  • Custom User Avatar

    your code passes that test ("single solution"). Either that's not the problem you're facing, or you should reset the trainer.

    Closing

  • Default User Avatar

    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?

  • Custom User Avatar

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