Ad
  • Custom User Avatar

    I assume your code already finds a solution? I don't know what approach you took but you can memoize any found solution and let your code continue search, so if it does find any other solution afterwards it throws or if it runs out of options it either returns the only solution or throws if none was found.

  • Default User Avatar

    Could you give me a hint what i have to check to find this kind of case ?
    I know i have to check for at least 17 givens and that at least 8 different numbers are used. But other than that im kinda lost^^

  • Custom User Avatar

    First one has two solutions, which should result in error, so the problem is in your code.

  • Default User Avatar
     int[][] p1 = {{9,0,6,0,7,0,4,0,3},
                {0,0,0,4,0,0,2,0,0},
                {0,7,0,0,2,3,0,1,0},
                {5,0,0,0,0,0,1,0,0},
                {0,4,0,2,0,8,0,6,0},
                {0,0,3,0,0,0,0,0,5},
                {0,3,0,7,0,0,0,5,0},
                {0,0,7,0,0,5,0,0,0},
                {4,0,5,0,1,0,7,0,8}};
    
     int[][] p2 = {{3,4,7,9,0,0,0,8,0},
                {0,1,0,8,0,0,0,5,0},
                {0,0,0,0,0,0,0,1,0},
                {0,0,0,5,0,0,0,0,8},
                {0,0,0,4,0,8,0,0,0},
                {6,0,0,0,0,3,0,0,0},
                {0,7,0,0,0,0,0,0,0},
                {0,8,0,0,0,5,0,3,0},
                {0,5,0,0,0,4,2,7,9}};
    

    I found one solution for each of them.

    Why should they throw an IllegalArgumentException??

    There are more than 16 Given Numbers and also 8 different numbers given.

    The Grid size is valid.