Skip to main content
Commonmark migration
Source Link

#Sudoku solver

Sudoku solver

Please tag submissions with .

Given a Sudoku puzzle as input, find its solution (or determine that it is unsolvable or ambiguous).

The program must take as input a puzzle in the form of a 9×9 grid of digits and dots (the dots representing blank squares in the puzzle). For example:

...84...9
..1.....5
8...2146.
7.8....9.
.........
.5....3.1
.2491...7
9.....5..
3...84...

The program must determine which of the following cases applies:

  1. The puzzle is unsolvable: it has no solution.
  2. The puzzle has exactly one solution.
  3. The puzzle is ambiguous: it has two or more solutions.

In case #2, it must output the solution in the form of a 9×9 grid of digits. In the example above, there is exactly one solution:

632845179
471369285
895721463
748153692
163492758
259678341
524916837
986237514
317584926

Discussion about whether multi-solution puzzles are in fact Sudoku puzzles

 (edit by rolfl)

Since I originally suggested a Sudoku solver, perhaps I can explain my motivation for this. I have (occasionally) come across sudoku puzzles I cannot solve, for one reason or another. One application for the solution of this challenge, is to be able to, as a regular sudoku player, 'capture' the puzzle, and prove that my failure to solve is in fact my fault, and not the puzzle-setter's.

I fully intend to participate in this W-E Challenge (hopefully with my son), and the result of our work will hopefully enable us to (perhaps not on the first submission):

  • capture an initial puzzle (and perhaps later also a partially completed puzzle)
  • say whether there is an actual solution, and only one
  • identify any inconsistencies in the puzzle (did we make a mistake somewhere?)
  • suggest a potential 'move' that will assist in a solution (a 'hint' - X-Wing, Swordfish, etc.)
  • brute-force the puzzle to get the solution if we 'give up' on a puzzle.

The final product will allow us to easily 'capture' a (perhaps partially completed) puzzle, and choose what sort of assistance we want.

These are the ideas that were drifting through my mind when I suggested this as a W-E topic, but I thought the first order of business was probably just a brute-force solution, which would knock 3 of the 5 requirements off the list.

#Sudoku solver

Please tag submissions with .

Given a Sudoku puzzle as input, find its solution (or determine that it is unsolvable or ambiguous).

The program must take as input a puzzle in the form of a 9×9 grid of digits and dots (the dots representing blank squares in the puzzle). For example:

...84...9
..1.....5
8...2146.
7.8....9.
.........
.5....3.1
.2491...7
9.....5..
3...84...

The program must determine which of the following cases applies:

  1. The puzzle is unsolvable: it has no solution.
  2. The puzzle has exactly one solution.
  3. The puzzle is ambiguous: it has two or more solutions.

In case #2, it must output the solution in the form of a 9×9 grid of digits. In the example above, there is exactly one solution:

632845179
471369285
895721463
748153692
163492758
259678341
524916837
986237514
317584926

Discussion about whether multi-solution puzzles are in fact Sudoku puzzles

 (edit by rolfl)

Since I originally suggested a Sudoku solver, perhaps I can explain my motivation for this. I have (occasionally) come across sudoku puzzles I cannot solve, for one reason or another. One application for the solution of this challenge, is to be able to, as a regular sudoku player, 'capture' the puzzle, and prove that my failure to solve is in fact my fault, and not the puzzle-setter's.

I fully intend to participate in this W-E Challenge (hopefully with my son), and the result of our work will hopefully enable us to (perhaps not on the first submission):

  • capture an initial puzzle (and perhaps later also a partially completed puzzle)
  • say whether there is an actual solution, and only one
  • identify any inconsistencies in the puzzle (did we make a mistake somewhere?)
  • suggest a potential 'move' that will assist in a solution (a 'hint' - X-Wing, Swordfish, etc.)
  • brute-force the puzzle to get the solution if we 'give up' on a puzzle.

The final product will allow us to easily 'capture' a (perhaps partially completed) puzzle, and choose what sort of assistance we want.

These are the ideas that were drifting through my mind when I suggested this as a W-E topic, but I thought the first order of business was probably just a brute-force solution, which would knock 3 of the 5 requirements off the list.

Sudoku solver

Please tag submissions with .

Given a Sudoku puzzle as input, find its solution (or determine that it is unsolvable or ambiguous).

The program must take as input a puzzle in the form of a 9×9 grid of digits and dots (the dots representing blank squares in the puzzle). For example:

...84...9
..1.....5
8...2146.
7.8....9.
.........
.5....3.1
.2491...7
9.....5..
3...84...

The program must determine which of the following cases applies:

  1. The puzzle is unsolvable: it has no solution.
  2. The puzzle has exactly one solution.
  3. The puzzle is ambiguous: it has two or more solutions.

In case #2, it must output the solution in the form of a 9×9 grid of digits. In the example above, there is exactly one solution:

632845179
471369285
895721463
748153692
163492758
259678341
524916837
986237514
317584926

Discussion about whether multi-solution puzzles are in fact Sudoku puzzles

 (edit by rolfl)

Since I originally suggested a Sudoku solver, perhaps I can explain my motivation for this. I have (occasionally) come across sudoku puzzles I cannot solve, for one reason or another. One application for the solution of this challenge, is to be able to, as a regular sudoku player, 'capture' the puzzle, and prove that my failure to solve is in fact my fault, and not the puzzle-setter's.

I fully intend to participate in this W-E Challenge (hopefully with my son), and the result of our work will hopefully enable us to (perhaps not on the first submission):

  • capture an initial puzzle (and perhaps later also a partially completed puzzle)
  • say whether there is an actual solution, and only one
  • identify any inconsistencies in the puzzle (did we make a mistake somewhere?)
  • suggest a potential 'move' that will assist in a solution (a 'hint' - X-Wing, Swordfish, etc.)
  • brute-force the puzzle to get the solution if we 'give up' on a puzzle.

The final product will allow us to easily 'capture' a (perhaps partially completed) puzzle, and choose what sort of assistance we want.

These are the ideas that were drifting through my mind when I suggested this as a W-E topic, but I thought the first order of business was probably just a brute-force solution, which would knock 3 of the 5 requirements off the list.

added 47 characters in body
Source Link
200_success
  • 144.1k
  • 4
  • 113
  • 280

#Sudoku solver

Please tag submissions with .

Given a Sudoku puzzle as input, find its solution (or determine that it is unsolvable or ambiguous).

The program must take as input a puzzle in the form of a 9×9 grid of digits and dots (the dots representing blank squares in the puzzle). For example:

...84...9
..1.....5
8...2146.
7.8....9.
.........
.5....3.1
.2491...7
9.....5..
3...84...

The program must determine which of the following cases applies:

  1. The puzzle is unsolvable: it has no solution.
  2. The puzzle has exactly one solution.
  3. The puzzle is ambiguous: it has two or more solutions.

In case #2, it must output the solution in the form of a 9×9 grid of digits. In the example above, there is exactly one solution:

632845179
471369285
895721463
748153692
163492758
259678341
524916837
986237514
317584926

Discussion about whether multi-solution puzzles are in fact Sudoku puzzles

 (edit by rolfl)

Since I originally suggested a Sudoku solver, perhaps I can explain my motivation for this. I have (occasionally) come across sudoku puzzles I cannot solve, for one reason or another. One application for the solution of this challenge, is to be able to, as a regular sudoku player, 'capture' the puzzle, and prove that my failure to solve is in fact my fault, and not the puzzle-setter's.

I fully intend to participate in this W-E Challenge (hopefully with my son), and the result of our work will hopefully enable us to (perhaps not on the first submission):

  • capture an initial puzzle (and perhaps later also a partially completed puzzle)
  • say whether there is an actual solution, and only one
  • identify any inconsistencies in the puzzle (did we make a mistake somewhere?)
  • suggest a potential 'move' that will assist in a solution (a 'hint' - X-Wing, Swordfish, etc.)
  • brute-force the puzzle to get the solution if we 'give up' on a puzzle.

The final product will allow us to easily 'capture' a (perhaps partially completed) puzzle, and choose what sort of assistance we want.

These are the ideas that were drifting through my mind when I suggested this as a W-E topic, but I thought the first order of business was probably just a brute-force solution, which would knock 3 of the 5 requirements off the list.

#Sudoku solver

Given a Sudoku puzzle as input, find its solution (or determine that it is unsolvable or ambiguous).

The program must take as input a puzzle in the form of a 9×9 grid of digits and dots (the dots representing blank squares in the puzzle). For example:

...84...9
..1.....5
8...2146.
7.8....9.
.........
.5....3.1
.2491...7
9.....5..
3...84...

The program must determine which of the following cases applies:

  1. The puzzle is unsolvable: it has no solution.
  2. The puzzle has exactly one solution.
  3. The puzzle is ambiguous: it has two or more solutions.

In case #2, it must output the solution in the form of a 9×9 grid of digits. In the example above, there is exactly one solution:

632845179
471369285
895721463
748153692
163492758
259678341
524916837
986237514
317584926

Discussion about whether multi-solution puzzles are in fact Sudoku puzzles

 (edit by rolfl)

Since I originally suggested a Sudoku solver, perhaps I can explain my motivation for this. I have (occasionally) come across sudoku puzzles I cannot solve, for one reason or another. One application for the solution of this challenge, is to be able to, as a regular sudoku player, 'capture' the puzzle, and prove that my failure to solve is in fact my fault, and not the puzzle-setter's.

I fully intend to participate in this W-E Challenge (hopefully with my son), and the result of our work will hopefully enable us to (perhaps not on the first submission):

  • capture an initial puzzle (and perhaps later also a partially completed puzzle)
  • say whether there is an actual solution, and only one
  • identify any inconsistencies in the puzzle (did we make a mistake somewhere?)
  • suggest a potential 'move' that will assist in a solution (a 'hint' - X-Wing, Swordfish, etc.)
  • brute-force the puzzle to get the solution if we 'give up' on a puzzle.

The final product will allow us to easily 'capture' a (perhaps partially completed) puzzle, and choose what sort of assistance we want.

These are the ideas that were drifting through my mind when I suggested this as a W-E topic, but I thought the first order of business was probably just a brute-force solution, which would knock 3 of the 5 requirements off the list.

#Sudoku solver

Please tag submissions with .

Given a Sudoku puzzle as input, find its solution (or determine that it is unsolvable or ambiguous).

The program must take as input a puzzle in the form of a 9×9 grid of digits and dots (the dots representing blank squares in the puzzle). For example:

...84...9
..1.....5
8...2146.
7.8....9.
.........
.5....3.1
.2491...7
9.....5..
3...84...

The program must determine which of the following cases applies:

  1. The puzzle is unsolvable: it has no solution.
  2. The puzzle has exactly one solution.
  3. The puzzle is ambiguous: it has two or more solutions.

In case #2, it must output the solution in the form of a 9×9 grid of digits. In the example above, there is exactly one solution:

632845179
471369285
895721463
748153692
163492758
259678341
524916837
986237514
317584926

Discussion about whether multi-solution puzzles are in fact Sudoku puzzles

 (edit by rolfl)

Since I originally suggested a Sudoku solver, perhaps I can explain my motivation for this. I have (occasionally) come across sudoku puzzles I cannot solve, for one reason or another. One application for the solution of this challenge, is to be able to, as a regular sudoku player, 'capture' the puzzle, and prove that my failure to solve is in fact my fault, and not the puzzle-setter's.

I fully intend to participate in this W-E Challenge (hopefully with my son), and the result of our work will hopefully enable us to (perhaps not on the first submission):

  • capture an initial puzzle (and perhaps later also a partially completed puzzle)
  • say whether there is an actual solution, and only one
  • identify any inconsistencies in the puzzle (did we make a mistake somewhere?)
  • suggest a potential 'move' that will assist in a solution (a 'hint' - X-Wing, Swordfish, etc.)
  • brute-force the puzzle to get the solution if we 'give up' on a puzzle.

The final product will allow us to easily 'capture' a (perhaps partially completed) puzzle, and choose what sort of assistance we want.

These are the ideas that were drifting through my mind when I suggested this as a W-E topic, but I thought the first order of business was probably just a brute-force solution, which would knock 3 of the 5 requirements off the list.

add discussion about single-solution.
Source Link
rolfl
  • 97.5k
  • 4
  • 116
  • 237

#Sudoku solver

Given a Sudoku puzzle as input, find its solution (or determine that it is unsolvable or ambiguous).

The program must take as input a puzzle in the form of a 9×9 grid of digits and dots (the dots representing blank squares in the puzzle). For example:

...84...9
..1.....5
8...2146.
7.8....9.
.........
.5....3.1
.2491...7
9.....5..
3...84...

The program must determine which of the following cases applies:

  1. The puzzle is unsolvable: it has no solution.
  2. The puzzle has exactly one solution.
  3. The puzzle is ambiguous: it has two or more solutions.

In case #2, it must output the solution in the form of a 9×9 grid of digits. In the example above, there is exactly one solution:

632845179
471369285
895721463
748153692
163492758
259678341
524916837
986237514
317584926

Discussion about whether multi-solution puzzles are in fact Sudoku puzzles

 (edit by rolfl)

Since I originally suggested a Sudoku solver, perhaps I can explain my motivation for this. I have (occasionally) come across sudoku puzzles I cannot solve, for one reason or another. One application for the solution of this challenge, is to be able to, as a regular sudoku player, 'capture' the puzzle, and prove that my failure to solve is in fact my fault, and not the puzzle-setter's.

I fully intend to participate in this W-E Challenge (hopefully with my son), and the result of our work will hopefully enable us to (perhaps not on the first submission):

  • capture an initial puzzle (and perhaps later also a partially completed puzzle)
  • say whether there is an actual solution, and only one
  • identify any inconsistencies in the puzzle (did we make a mistake somewhere?)
  • suggest a potential 'move' that will assist in a solution (a 'hint' - X-Wing, Swordfish, etc.)
  • brute-force the puzzle to get the solution if we 'give up' on a puzzle.

The final product will allow us to easily 'capture' a (perhaps partially completed) puzzle, and choose what sort of assistance we want.

These are the ideas that were drifting through my mind when I suggested this as a W-E topic, but I thought the first order of business was probably just a brute-force solution, which would knock 3 of the 5 requirements off the list.

#Sudoku solver

Given a Sudoku puzzle as input, find its solution (or determine that it is unsolvable or ambiguous).

The program must take as input a puzzle in the form of a 9×9 grid of digits and dots (the dots representing blank squares in the puzzle). For example:

...84...9
..1.....5
8...2146.
7.8....9.
.........
.5....3.1
.2491...7
9.....5..
3...84...

The program must determine which of the following cases applies:

  1. The puzzle is unsolvable: it has no solution.
  2. The puzzle has exactly one solution.
  3. The puzzle is ambiguous: it has two or more solutions.

In case #2, it must output the solution in the form of a 9×9 grid of digits. In the example above, there is exactly one solution:

632845179
471369285
895721463
748153692
163492758
259678341
524916837
986237514
317584926

#Sudoku solver

Given a Sudoku puzzle as input, find its solution (or determine that it is unsolvable or ambiguous).

The program must take as input a puzzle in the form of a 9×9 grid of digits and dots (the dots representing blank squares in the puzzle). For example:

...84...9
..1.....5
8...2146.
7.8....9.
.........
.5....3.1
.2491...7
9.....5..
3...84...

The program must determine which of the following cases applies:

  1. The puzzle is unsolvable: it has no solution.
  2. The puzzle has exactly one solution.
  3. The puzzle is ambiguous: it has two or more solutions.

In case #2, it must output the solution in the form of a 9×9 grid of digits. In the example above, there is exactly one solution:

632845179
471369285
895721463
748153692
163492758
259678341
524916837
986237514
317584926

Discussion about whether multi-solution puzzles are in fact Sudoku puzzles

 (edit by rolfl)

Since I originally suggested a Sudoku solver, perhaps I can explain my motivation for this. I have (occasionally) come across sudoku puzzles I cannot solve, for one reason or another. One application for the solution of this challenge, is to be able to, as a regular sudoku player, 'capture' the puzzle, and prove that my failure to solve is in fact my fault, and not the puzzle-setter's.

I fully intend to participate in this W-E Challenge (hopefully with my son), and the result of our work will hopefully enable us to (perhaps not on the first submission):

  • capture an initial puzzle (and perhaps later also a partially completed puzzle)
  • say whether there is an actual solution, and only one
  • identify any inconsistencies in the puzzle (did we make a mistake somewhere?)
  • suggest a potential 'move' that will assist in a solution (a 'hint' - X-Wing, Swordfish, etc.)
  • brute-force the puzzle to get the solution if we 'give up' on a puzzle.

The final product will allow us to easily 'capture' a (perhaps partially completed) puzzle, and choose what sort of assistance we want.

These are the ideas that were drifting through my mind when I suggested this as a W-E topic, but I thought the first order of business was probably just a brute-force solution, which would knock 3 of the 5 requirements off the list.

Source Link
Mathieu Guindon
  • 75.1k
  • 4
  • 98
  • 241
Loading