-
Notifications
You must be signed in to change notification settings - Fork 42
Interview Q&A
Avery Lieu edited this page Feb 11, 2017
·
37 revisions
Explain how you would fill in one 3x3 sub-grid in Sudoku algorithmically with each horizontal, vertical, and diagonal adding up to 15.
Example:
| a | b | c |
|---|---|---|
| d | e | f |
| g | h | i |
Horizontally:
- a + b + c = 15
- d + e + f = 15
- g + h + i = 15
Vertically:
- a + d + g = 15
- b + e + h = 15
- c + f + i = 15
Diagonally:
- a + e + i = 15
- g + e + c = 15
Explanation:
- Find all of the possible combinations adding up to 15
⋅⋅⋅ 1 + 9 + 5, 2 + 8 + 5, 3 + 7 + 5, 4 + 6 + 5
- Keep track of how many unique combinations each number can be apart of
⋅⋅⋅ In the above example, 5 is used 4 times
- Note how many combinations each square requires
⋅⋅⋅|3|2|3| ⋅⋅⋅|:---|:---|:---| ⋅⋅⋅|2|4|2| ⋅⋅⋅|3|2|3|