SillySudoku
SRM 315 · 2006-08-09 · by Cosmin.ro
Problem Statement
Little Johnny has just learned about Sudoku, but finds these puzzles annoyingly hard, so he plays a much simpler version. He plays on a 4x4 table where each cell is either empty or contains a single number between 1 and 4, inclusive. The purpose of the game is to fill the entire table with numbers so that each row, each column, and each 2x2 square (labeled A, B, C, and D in the picture below) contains each of the numbers 1, 2, 3, and 4 exactly once.
You are given a
Constraints
- table will contain exactly 4 elements.
- Each element will have exactly four characters.
- Each character will be '-', '1', '2', '3' or '4'.
{"--21",
"--34",
"2143",
"3412"}
Returns: 1
This puzzle has only one solution: 4321 1234 2143 3412 Each row contains 1, 2, 3, and 4: 4321 1234 2143 3412 Each column contains 1, 2, 3, and 4: 4 3 2 1 1 2 3 4 2 1 4 3 3 4 1 2 And each of the four 2x2 squares contains 1, 2, 3, and 4: 43 21 12 34 21 43 34 12
{"--1-",
"--1-",
"----",
"----"}
Returns: 0
This is a clearly invalid puzzle since it contains two 1s in the upper right 2x2 square.
{"1---",
"-42-",
"-3--",
"----"}
Returns: 3
{"1---",
"--1-",
"-1--",
"---1"}
Returns: 18
{"1---",
"----",
"----",
"----"}
Returns: 72
Submissions are judged against all 91 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class SillySudoku with a public method int countWays(vector<string> board) · 91 test cases · 2 s / 256 MB per case