Ad
  • Custom User Avatar

    Thank you so much !!!

  • Custom User Avatar
    [5, 3, 4,  6, 7, 8,  9, 1, 2],
    [6, 7, 2,  1, 9, 5,  3, 4, 8],
    [1, 9, 8,  3, 4, 2,  5, 6, 7],
    
    [8, 5, 9,  7, 6, 1,  4, 2, 3],
    [4, 2, 6,  8, 5, 3,  7, 9, 1],
    [7, 1, 3,  9, 2, 4,  8, 5, 6],
    
    [9, 6, 1,  5, 3, 7,  2, 8, 4],
    [2, 8, 7,  4, 1, 9,  6, 3, 5],
    [3, 4, 5,  2, 8, 6,  1, 7, 9]
    

    Those are the 9 sub-squares, the one you picked isn't one of them.

  • Custom User Avatar

    So I searched for that and I found: Each of the 9 sub-squares, of size 3x3, contains a unique value from 1-9.
    This is what I mean, there for that square is not valid. So why should I get true ??
    Thanks!

  • Custom User Avatar

    Please follow the link to Wikipedia to see an example of sudoku board and what a valid "sub grid" is. Not every 3x3 square of the board is a subgrid where the rules apply, there's only 9 of them.

  • Custom User Avatar

    Hi
    looking at the test:
    Test.assertEquals(validSolution([
    [5, 3, 4, 6, 7, 8, 9, 1, 2],
    [6, 7, 2, 1, 9, 5, 3, 4, 8],
    [1, 9, 8, 3, 4, 2, 5, 6, 7],
    [8, 5, 9, 7, 6, 1, 4, 2, 3],
    [4, 2, 6, 8, 5, 3, 7, 9, 1],
    [7, 1, 3, 9, 2, 4, 8, 5, 6],
    [9, 6, 1, 5, 3, 7, 2, 8, 4],
    [2, 8, 7, 4, 1, 9, 6, 3, 5],
    [3, 4, 5, 2, 8, 6, 1, 7, 9]]), true);

    According to the definitions, every sub grid 3X3 should contain 1-9 digits.
    As far as I see, please look at the sub grid starting on position [0, 2] - the number 4
    See that it's missing number 5:
    4,6,7
    2,1,9
    8,3,4
    Maybe I miss something.
    Thanks

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution