z-sudoku3
Little Z noticed his father Mr Z playing a game of sudoku. He asked his father to give him a try to solve the puzzle. But, because Mr Z knows that his son is still young and won't be able to solve a sudoku with 9X9 board, he decided to give him a easier version of the game. He made a sudoku board with dimensions 4x4 with the following rules:
• 4 different characters need to be put into a 4x4 board.
• Every character has to be used exactly 4 times.
• There can not be 2 same characters in a single row.
• There can not be 2 same characters in a single column.
• There can not be 2 same characters in any of the 2x2 sub-squares (as shown on the figure below).
+---+--+
|1 2|3 4|
|3 4|1 2|
+--+---+
|2 1|4 3|
|4 3|2 1|
+--+---+
Little Z tried to solve the puzzle, but he had difficulties, so because he knows you are a good programmer, he asked you to write a program for him to solve the puzzle.
In the second example, the puzzle can have multiple solutions, so we output any one of them.
• 4 different characters need to be put into a 4x4 board.
• Every character has to be used exactly 4 times.
• There can not be 2 same characters in a single row.
• There can not be 2 same characters in a single column.
• There can not be 2 same characters in any of the 2x2 sub-squares (as shown on the figure below).
+---+--+
|1 2|3 4|
|3 4|1 2|
+--+---+
|2 1|4 3|
|4 3|2 1|
+--+---+
Little Z tried to solve the puzzle, but he had difficulties, so because he knows you are a good programmer, he asked you to write a program for him to solve the puzzle.
InputThe first 4 lines of the standard input will contain 4 characters, representing the puzzle. The characters will be 1 to 4 or . (dot) The dot represents an empty field.
OutputTo the standard output you should write the solution of the puzzle. If there are multiple solutions, you can print any one of them, as long as the solution is correct.
Input
Output
123.
3412
214.
4321Output
1234
3412
2143
4321Input
Output
..14
....
....
....Output
3214
1423
2341
4132In the second example, the puzzle can have multiple solutions, so we output any one of them.
Submit solution
Coming laterThe grading service will be connected in a later migration step. You can inspect the task and your previous results now.