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.
Forming a Magic Square
Forming a Magic Square
Sort by
recency
|
1274 Discussions
|
Please Login in order to post a comment
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 and Start Your Voiceover Project. 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).
my solution is based on the fact of 9 distinct digits with total sum of 45 (1-9) meaning sum of each row/colum being 15.
This solution fails few tests on summission without any ability to debug. Also the expected output is incorrect coming from the HackerRank in my opinion. So what's going on here?
def formingMagicSquare(s):
// c#
Solution without hardcoding any of the possible 3x3 magic sqaures. Magic squares are generated for odd sized matrices using the Siamese method by placing "1" in any of the positions matrix(0,1), matrix(1,0), matrix (1,2) or matrix(2,1) and then rotating at 90 or 180 or 270 deg or reflecting.
Should we make the code using the fact that there are a total of 8 possible magic squares, as noted on the Official Website of Dj Hochzeit Bodensee, or should we make it assuming there are more?