Validate Sudoku (N by N)

0

Challenge :

Create a random (pseudo random) Sudoku board with dimension n x n


Input :

Given :

  • n where :

    2 < n < 100


Output :

true / false depending on whether the board is valid or not.


Examples :

For n = 3 :

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

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

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

This is ^ the random generated board.

Output : true


Note :

  • This is so shortest code in bytes (for each programming language) wins.
  • Given input n will always be an integer (non-decimal value) and between the two mentioned constrains

Muhammad Salman

Posted 2018-05-25T17:19:33.893

Reputation: 2 361

Question was closed 2018-05-25T17:32:59.330

In my opinion, this is too close to this, but I won't hammer it...

– Stewie Griffin – 2018-05-25T17:26:28.170

1We're supposed to create a random board then decide whether it is valid? Maybe simply generating a random valid board would be a better challenge. – dylnan – 2018-05-25T17:34:13.873

6@StewiwGriffin I’ve read both challenges carefully and I think that the differences are insignificant, so I chose to hammer-close it as a dupe. If I would have had the option to VTC but not hammer, I would have done so. – Mr. Xcoder – 2018-05-25T17:34:27.473

@Mr.Xcoder : I disagree with you – Muhammad Salman – 2018-05-25T17:40:47.900

4I think it's a duplicate, too. There is already a challenge for validating, so the only difference is that you need to generate a random 9x9 matrix. So basically the entire hard (challenge) part already exists elsewhere on the site. – mbomb007 – 2018-05-25T17:50:42.313

@MuhammadSalman Feel free to, this is solely my opinion. – Mr. Xcoder – 2018-05-25T17:51:17.423

@MuhammadSalman If you change the challenge to my suggestion above I think it would be reopened and it would be a good challenge – dylnan – 2018-05-26T00:22:27.023

1@dylnan Still not that different. Then it's just do { x = random_board(); } while ( invalid_board(x) ); – user202729 – 2018-05-26T03:16:01.880

1@user202729 true. Maybe if you were asked to generate a valid board at size of the input that didn’t need to be random it wouldn’t be the same method – dylnan – 2018-05-26T14:16:46.840

No answers