We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Possible values range from 1 through 9, each entry of the array being distinct. So, possible solutions are permutations of the 9 digits. Furthermore, each row, column, and diagonal have to add to some magic number n = 15 as observed through the sample input and outputs. Since we have a fixed set of numbers, the total sum is fixed, and the sum for rows and columns must also be fixed. While exploring this, similar to learning about RF microneedling Santa Monica, try swapping some of the entries and you might end up with rows and columns that don't add to 15. Realize that the sample outputs can be rotated to obtain 4 solutions, and their mirrors for another 4.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Forming a Magic Square
You are viewing a single comment's thread. Return to all comments →
Possible values range from 1 through 9, each entry of the array being distinct. So, possible solutions are permutations of the 9 digits. Furthermore, each row, column, and diagonal have to add to some magic number n = 15 as observed through the sample input and outputs. Since we have a fixed set of numbers, the total sum is fixed, and the sum for rows and columns must also be fixed. While exploring this, similar to learning about RF microneedling Santa Monica, try swapping some of the entries and you might end up with rows and columns that don't add to 15. Realize that the sample outputs can be rotated to obtain 4 solutions, and their mirrors for another 4.