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
- Discussions
Forming a Magic Square
Forming a Magic Square
Sort by
recency
|
36 Discussions
|
Please Login in order to post a comment
Python 3:
Solution in CPP, building all magic squares:
Not as bad a question as some people here make out.
Generate all permutations of list [1,2,3,4,5,6,7,8,9] (the list is a flattened square 3x3 2D array)
Filter for lists that are magic (the criteria are in the question)
Calculate distance from input array to each magic square
Return minimum distance
Python3 2 line:
Java, O(1)