# Sudoku Logic Test

So I have never really played Sudoku, but a guy in an interview asked me if I knew the logic to Sudoku....

I was like no, but he said people know the logic to it and they how its coded...

Do you know how to code it??

[quote=“deffury, post:, topic:”]

Do you know how to code it??

[/quote]

what are you trying to say, It's really hard to understand...

1) "Source Code" logic of a program to create "Sudoku Puzzle"

OR

2) "Source Code" logic of a program to solve "Sudoku Puzzle"

In both scenario 2D array is the heart of logic and it is better to think of the two-dimensional array as a matrix in most of cases.

Edit:

@deffury

go for "Magic Box"

the guy asked logic in any form..

it can be pseudocode or source code....

Are you up fora challenge..... The post is meant to help others in interviews...

this is not a school assignment

[quote=“deffury, post:3, topic:19498”]

the guy asked logic in any form..

it can be pseudocode or source code....

[/quote]

1) "Source Code" logic of a program to create "Sudoku Puzzle"

OR

2) "Source Code" logic of a program to solve "Sudoku Puzzle"

[quote="deffury, post:3, topic:19498"]

The post is meant to help others in interviews...

[/quote]

[quote="deffury, post:3, topic:19498"]

Are you up fora challenge

[/quote]

what challenge?

bro,

dont like it, dont do it....

I think it would go about like:

1. declare a 3 dimensional array

2. apply nested loops for each values in column and rows

3. apply another set of loops within which determines the missing numbers, and adds them

4. A condition will check if there are any empty values within the matrix...if yes continue otherwise break loops and end program.

I have been wondering if Arraylist can be used too.....

What do you think??

[quote=“deffury, post:6, topic:19498”]

1. declare a 3 dimensional array

[/quote]

@ deffury

This is not personal,
Did you know 3 dimensional array and its purpose?

Let me try,
You want to show your data in 2 axis X,Y
fine go for 2d array.
You want to show your data in 3 axis X,Y,Z
then go for 3d array
But first answer this Q,s if you really interested in Soduko

Logic of a program to create "Sudoku Puzzle"

OR

Logic of a program to solve "Sudoku Puzzle"

Asif.

none taken,

solve it or create it, is up to you...

[quote=“deffury, post:8, topic:19498”]

none taken,

[/quote]
Ah well, if you know it better.

[quote="deffury, post:8, topic:19498"]

solve it or create it, is up to you...

[/quote]

??!??

Would it make you feel better if I changed the question, or made it less challenging for you

[quote=“deffury, post:10, topic:19498”]

Would it make you feel better if I changed the question, or made it less challenging for you

Posted, Yesterday, 04:05 PM

Edited, Yesterday, 08:40 PM
[/quote]

First think then speak

[quote="deffury, post:10, topic:19498"]

Would it make you feel better if I changed the question, or made it less challenging for you

[/quote]

I am a Grumpy Old Man, at this age don't like challenges.
"You Win"
KO

, kid!

Its was never a competition, just a service to those who need help

you dont like the question, then dont crap about it

if you know it then do it, if you dont know it then leave with whatever dignity you have....

Regards

WP's Grumpy old man

1. declare a 3 dimensional array

2. apply nested loops for each values in column and rows

3. apply another set of loops within which determines the missing numbers, and adds them

4. A condition will check if there are any empty values within the matrix...if yes continue otherwise break loops and end program.

Thanks aanaya

I had to do it for an assignment. I tried solving using human-ish logic, i.e. see what values could fit in there and apply those, it didn't work for a lot of puzzles. Then used recursion with backtracking which works quite well. Basically you assume a value for a block, check if it conflicts with the board, if it does assume another number, if it doesn't assume it is correct. Then move on to the next block and assume a value, if all 9 values conflict in this block, you move back to the previous block and try another value for that block and continue. The base case is when row 9 (rows 0-8 are the sudoku board) has been reached, i.e. the puzzle has been solved and the recursive function returns true when 9 is passed to it.