Deception
CodeChefOpen on judge ↗
A magic square is an $n x n$ square matrix of distinct positive integers from $1$ to $n^2$ where the sum of any row, column, or diagonal of length n is always equal to the same number: the magic constant. You will be given a $3 x 3$ matrix of $s$ integers in the range $[1,9] $. We can convert any digit a to any other digit b in the range $[1,9] $ at a cost of $|a-b|$ . Given $s$ , convert it into
HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17
CodeSearch Tutor
Hints, not spoilers — it won’t hand over the full solution unless you insist.
Sign in to chat with the tutor and save your progress.
Sign in to start