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.
My opinion is:
Think of the 3 x 3 magic square as a ring except for the 5 in the middle:
Because 5 must be in the middle
So we just compare the source (List s) with the standard magic square (Array magic in this case)
In the process, you need to compare things going forward, and you also need to compare things going backward.
In the forward direction: 4→9→2→7→6→1→8→3, the next round: 2→7→6→1→8→3→4→9, advancing 2 spaces each time, and so on...
Reverse: 8→1→6→7→2→9→4→3, next round: 6→7→2→9→4→3→8→1, advance 2 spaces each time, and so on...
Forming a Magic Square
You are viewing a single comment's thread. Return to all comments →
C# solution
我的想法是: 將3 x 3的magic square除了中間的5之外視為一個環: 因為5一定在最中間 所以我們只要將來源(List s)與標準的magic square(這裡是 Array magic)做比較就可以了 過程中,順向的要比較,逆向的也要比較 順向的:4→9→2→7→6→1→8→3,下一輪:2→7→6→1→8→3→4→9,每次前進2格,以此類推… 逆向的:8→1→6→7→2→9→4→3,下一輪:6→7→2→9→4→3→8→1,每次前進2格,以此類推…
My opinion is: Think of the 3 x 3 magic square as a ring except for the 5 in the middle: Because 5 must be in the middle So we just compare the source (List s) with the standard magic square (Array magic in this case) In the process, you need to compare things going forward, and you also need to compare things going backward. In the forward direction: 4→9→2→7→6→1→8→3, the next round: 2→7→6→1→8→3→4→9, advancing 2 spaces each time, and so on... Reverse: 8→1→6→7→2→9→4→3, next round: 6→7→2→9→4→3→8→1, advance 2 spaces each time, and so on...