HKOI 2006 Analysis and Solution Junior Q 3

  • Slides: 17
Download presentation
HKOI 2006 Analysis and Solution Junior Q 3 – Sudoku HKOI Training Team 2006

HKOI 2006 Analysis and Solution Junior Q 3 – Sudoku HKOI Training Team 2006 -01 -07

Statistics n n n Attempts: 42 (out of 69) Mean: 46. 91 Max: 100

Statistics n n n Attempts: 42 (out of 69) Mean: 46. 91 Max: 100 (3) Min: 0 Std Dev: 41. 05

Statistics

Statistics

The Problem n n Given an incomplete Sudoku puzzle, solve for the remaining cells

The Problem n n Given an incomplete Sudoku puzzle, solve for the remaining cells Only the center 9 cells are empty

Observation n For each test case, there is at most one solution n Why?

Observation n For each test case, there is at most one solution n Why?

Observations n For any cell in the center region, there must be exactly one

Observations n For any cell in the center region, there must be exactly one number that can be filled in without any violation to the rules n n Why? Let’s prove it by contradiction…

Observations n Suppose ‘ 1’ and ‘ 2’ can both be filled in the

Observations n Suppose ‘ 1’ and ‘ 2’ can both be filled in the center cell without violation to rules

Observations n Fill ‘ 1’ into the center cell 1

Observations n Fill ‘ 1’ into the center cell 1

Observations n Why can ‘ 2’ be filled in the center cell? 1

Observations n Why can ‘ 2’ be filled in the center cell? 1

Observations n Because it has not appeared in the center row nor the center

Observations n Because it has not appeared in the center row nor the center column 1

Observations n So ‘ 2’ must be filled in somewhere in the center row,

Observations n So ‘ 2’ must be filled in somewhere in the center row, and also the column 1

Observations n ‘ 2’ has to be appeared in one of the two Red

Observations n ‘ 2’ has to be appeared in one of the two Red cells, and also one of the two yellow cells 1

Observations n Since all 4 colored cells are in the same region, two ‘

Observations n Since all 4 colored cells are in the same region, two ‘ 2’s must be in the same region Contradiction 1

Solutions n n For each cell, find if these is exactly one number to

Solutions n n For each cell, find if these is exactly one number to fill in “No solution” if none or >1 is found

Alternative Solution n Exhaust all possible permutations of 1 to 9 to find in

Alternative Solution n Exhaust all possible permutations of 1 to 9 to find in the cells, then check whether the solution is valid n This solution looks stupid, but it works since there are only 9! = 362880 permutations in total

Common Mistakes n n Forgot to handle the “No solution” case Assume there are

Common Mistakes n n Forgot to handle the “No solution” case Assume there are no violations in the numbers already filled in

Questions?

Questions?