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.
This constant sum is known as the magic constant or magic sum. Magic squares have fascinated mathematicians for centuries and often appear in puzzles, artwork, and historical texts Get It Now. The process of creating one can vary depending on whether the square has an odd, even, or doubly even order (such as 3x3, 4x4, or 6x6).
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Join us
Create a HackerRank account
Be part of a 26 million-strong community of developers
Please signup or login in order to view this challenge
Forming a Magic Square
You are viewing a single comment's thread. Return to all comments →
for matrix 6 1 2 7 2 6 5 6 2
cost is coming as 18 but it should be 20 as most economical transformation will be
6 1 8 7 5 3 2 9 4
8 1 6 3 5 7 4 9 2 is 18
This constant sum is known as the magic constant or magic sum. Magic squares have fascinated mathematicians for centuries and often appear in puzzles, artwork, and historical texts Get It Now. The process of creating one can vary depending on whether the square has an odd, even, or doubly even order (such as 3x3, 4x4, or 6x6).