Sudoku (1)

Write a program that finds all the possible solutions of a sudoku.

Input

Input consists of 81 numbers between zero and nine, plus the bars and
dashes that can be seen at the instances. The zeros indicate positions
of unknown value. Except zeros, there will not be any repeated number in
any row, nor any column, nor any of the nine squares 3 × 3.

Output

Your program must print all the possible solutions of the given sudoku,
in lexicographical order, and each one with a line in white in the end.
It must print "-1" if there is not any possible solution.

Observation

The test data of this exercise are done in a way that a backtracking
that simply fulls the rows from top to bottom and from left to right is
fast enough.

Problem information

Author: Unknown
Translator: Carlos Molina

Generation: 2026-01-25T12:20:12.293Z

© Jutge.org, 2006–2026.
https://jutge.org
