Problem 42853. Fifteen Parity Check
The Matlab function fifteen initializes the 4x4 array with randperm(16), which produces 50% unsolvable puzzles. A two stage parity check from wikipedia details the method of distance of the empty cell to index 16 plus the number of swaps to produce a 1:16 sequence must be Even to be a valid puzzle. The 16 is the empty space.
Given a 4x4 matrix determine if it is valid(1) or invalid(0).
1 2 3 4 1 2 3 4 5 6 7 8 5 6 7 8 9 10 11 12 9 10 11 12 13 15 14 16 Invalid(0) 13 14 16 15 Valid(1)
Who can come up with the best fifteen_check to fix the fifteen function?
Solution Stats
Problem Comments
Solution Comments
Show commentsProblem Recent Solvers21
Suggested Problems
-
Remove all the words that end with "ain"
2471 Solvers
-
Project Euler: Problem 6, Natural numbers, squares and sums.
2347 Solvers
-
143 Solvers
-
Back to basics 11 - Max Integer
793 Solvers
-
Reverse the elements of an array
1057 Solvers
More from this Author308
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!