6 kyu
Odd Magic Square
182 of 276Abelard_Snazz
Description:
Your task is to create a magic square for any positive odd integer N
. The magic square contains the integers from 1
to N * N
, arranged in an NxN
matrix, such that the columns, rows and both main diagonals add up to the same number.
Note: use have to use the Siamese method for this task.
Examples:
n = 3
result = [
[8, 1, 6],
[3, 5, 7],
[4, 9, 2]
]
n = 5
result = [
[17, 24, 1, 8, 15],
[23, 5, 7, 14, 16],
[ 4, 6, 13, 20, 22],
[10, 12, 19, 21, 3],
[11, 18, 25, 2, 9]
]
Puzzles
Arrays
Mathematics
Similar Kata:
Stats:
Created | Apr 11, 2016 |
Published | Apr 11, 2016 |
Warriors Trained | 683 |
Total Skips | 42 |
Total Code Submissions | 768 |
Total Times Completed | 276 |
Python Completions | 182 |
Go Completions | 17 |
Rust Completions | 32 |
JavaScript Completions | 67 |
Total Stars | 23 |
% of votes with a positive feedback rating | 94% of 97 |
Total "Very Satisfied" Votes | 85 |
Total "Somewhat Satisfied" Votes | 12 |
Total "Not Satisfied" Votes | 0 |
Total Rank Assessments | 10 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 5 kyu |
Lowest Assessed Rank | 7 kyu |