Sumdoku is a variant of the game Sudoku.
As in Sudoku, the aim is to fill in a -by- grid with the digits through so that each digit through occurs exactly once in each row,
exactly once in each column and exactly once in each of the
-by- sub-squares subject to constraints
on the choices. In Sudoku, the constraints are that certain
squares must contain fixed values. In Sumdoku, the
constraints are on the sum of adjacent squares within each
-by- sub-square. In the illustration
below, the symbols ,
and indicate that the sum of the
values on either side (or above and below) the symbol must have
sum less than , equal
to or greater than
, respectively.
Write a program to solve Sumdoku problems.
Input
The input consists of a single data set containing
lines of input, each
line consisting of the characters <, = or >. Rows , , , , , , , and contain characters corresponding to
constraints on the sum of values to the left and right of the
symbol. Rows ,
, , , and contain characters corresponding to
constraints on the sum of values above and below the symbol.
Note: Solutions of some problems may
not be unique. The judging program will just check whether your
solution satisfies the constraints of the problem (row, column,
-by- box and inequality
constraints).
Output
Output lines
consisting of decimal
digits each, separated by a single space. The value in the
position in
the line
of the output lines is
the solution value in column of row .
Sample Input 1 |
Sample Output 1 |
<==<=>
><>><<><=
>=<==<
><<><>><<
<<>==<
=<=>=>
>><<>=<><
><>>><
=====<<>>
<><<>>
<><><<
<>><>><>=
=>><=>
<><<><><>
<>=>=<
|
5 3 7 8 2 1 6 4 9
9 6 4 5 3 7 8 2 1
8 1 2 9 4 6 7 3 5
6 4 5 3 7 8 1 9 2
7 8 1 4 9 2 5 6 3
3 2 9 6 1 5 4 7 8
2 7 8 1 6 9 3 5 4
1 9 3 7 5 4 2 8 6
4 5 6 2 8 3 9 1 7
|