Gamified challenge · Constraint satisfaction
board is 4 strings of 4 characters: a digit 1-4 is given, . is empty. Fill every empty cell so that each row, each column and each of the four 2×2 boxes (rows 0-1 or 2-3, columns 0-1 or 2-3) contains 1, 2, 3 and 4 exactly once. Every puzzle has exactly one solution.
Write solve(board) returning the filled square as 4 strings, keeping the given digits. For ["....", "..34", "4..2", ".2.."] the answer is ["3421", "2134", "4312", "1243"].
Plain backtracking works; the Watch tab compares it with forward checking, the MRV heuristic and AC-3 constraint propagation, counting how many digits each one places and takes back.
This game is part of the paid plans. Sign in, then pick a plan to write your answer, watch it play out, and step through the algorithm with its guide.
Sign in with Google