Why would this input result in an invalid Sudoku?


  • 0
    B

    For input ["....5..1.",".4.3.....",".....3..1","8......2.","..2.7....",".15......",".....2...",".2.9.....","..4......"] my program returns true but the expected output is supposed to be false as reported by OJ? Can someone help me see why it is invalid?

    I gave the same input to my Sudoku solver to ensure there is a solution and it can be solved as below - which makes it more confusing on why it is invalid:

    . . . . 5 . . 1 .

    . 4 . 3 . . . . .

    . . . . . 3 . . 1

    8 . . . . . . 2 .

    . . 2 . 7 . . . .

    . 1 5 . . . . . .

    . . . . . 2 . . .

    . 2 . 9 . . . . .

    . . 4 . . . . . .

    Solved as:

    2 3 7 4 5 6 8 1 9

    1 4 8 3 9 7 2 5 6

    5 6 9 2 8 3 4 7 1

    8 7 6 1 3 4 9 2 5

    3 9 2 5 7 8 1 6 4

    4 1 5 6 2 9 3 8 7

    6 5 1 8 4 2 7 9 3

    7 2 3 9 1 5 6 4 8

    9 8 4 7 6 1 5 3 2


  • 2
    S

    2 3 7 4 5 6 8 [1] 9

    1 4 8 3 9 7 2 5 6

    5 6 9 2 8 3 4 7 [1]

    8 7 6 1 3 4 9 2 5

    3 9 2 5 7 8 1 6 4

    4 1 5 6 2 9 3 8 7

    6 5 1 8 4 2 7 9 3

    7 2 3 9 1 5 6 4 8

    9 8 4 7 6 1 5 3 2

    Those [1] in the same block. You looks misundertand the rules of sudoku.


  • 0
    H

    It is not valid. Look at the bold part. It contains two '1'.

    2 3 7 4 5 6 8 1 9

    1 4 8 3 9 7 2 5 6

    5 6 9 2 8 3 4 7 1

    8 7 6 1 3 4 9 2 5

    3 9 2 5 7 8 1 6 4

    4 1 5 6 2 9 3 8 7

    6 5 1 8 4 2 7 9 3

    7 2 3 9 1 5 6 4 8

    9 8 4 7 6 1 5 3 2


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.