### Inlaid 22x22 magic square

The challenge was to construct an inlaid magic square with even and odd inlay magic squares in it. See below how I did it.

The design

The design of the 20x20 inlay square is as follows:

In the corners are four 7x7 panmagic squares. Around the 7x7 panmagic squares are half borders. The ‘cross’ in the middle consists of five panmagic 4x4 squares (and eight half panmagic suares, in which two times two numbers have been swapped to make the magic square valid; see explained later). In the 20x20 inlay square (at first) are the numbers 1 up to 400 (later on added by 42). I used the numbers 103 up to 298 to construct the four panmagic 7x7 squares. I used the numbers 73 up to 102 and 299 up to 328 to construct the half borders. I used the numbers 1 up to 72 and 329 up to 400 to construct the five whole and eight half panmagic 4x4 squares.

The four panmagic 7x7 squares

To construct the four panmagic 7x7 squares we use the same method to construct a composite 21x21 magic square. As row coordinates we use the numbers 0 up to 6. As column coordinates we use the numbers 0 up to 27 and we try to get the four panmagic 7x7 squares as proportional as possible.

Column coordinates first square             Row coordinates first square

 0 4 11 13 18 23 25 0 1 2 3 4 5 6 11 13 18 23 25 0 4 3 4 5 6 0 1 2 18 23 25 0 4 11 13 6 0 1 2 3 4 5 25 0 4 11 13 18 23 2 3 4 5 6 0 1 4 11 13 18 23 25 0 5 6 0 1 2 3 4 13 18 23 25 0 4 11 1 2 3 4 5 6 0 23 25 0 4 11 13 18 4 5 6 0 1 2 3

7x column+1x row coord.+1+102 = First panmagic 7x7 square

 1 30 80 95 131 167 182 103 132 182 197 233 269 284 81 96 132 168 176 2 31 183 198 234 270 278 104 133 133 162 177 3 32 82 97 235 264 279 105 134 184 199 178 4 33 83 98 127 163 280 106 135 185 200 229 265 34 84 92 128 164 179 5 136 186 194 230 266 281 107 93 129 165 180 6 35 78 195 231 267 282 108 137 180 166 181 7 29 79 94 130 268 283 109 131 181 196 232

Column coordinates second square     Row coordinates second square

 2 5 9 15 16 21 26 0 1 2 3 4 5 6 9 15 16 21 26 2 5 3 4 5 6 0 1 2 16 21 26 2 5 9 15 6 0 1 2 3 4 5 26 2 5 9 15 16 21 2 3 4 5 6 0 1 5 9 15 16 21 26 2 5 6 0 1 2 3 4 15 16 21 26 2 5 9 1 2 3 4 5 6 0 21 26 2 5 9 15 16 4 5 6 0 1 2 3

7x column+1x row coord.+1+102 = Second panmagic 7x7 square

 15 37 66 109 117 153 189 117 139 168 211 219 255 291 67 110 118 154 183 16 38 169 212 220 256 285 118 140 119 148 184 17 39 68 111 221 250 286 119 141 170 213 185 18 40 69 112 113 149 287 120 142 171 214 215 251 41 70 106 114 150 186 19 143 172 208 216 252 288 121 107 115 151 187 20 42 64 209 217 253 289 122 144 166 152 188 21 36 65 108 116 254 290 123 138 167 210 218

Column coordinates third square          Row coordinates third square

 3 7 10 14 17 20 24 0 1 2 3 4 5 6 10 14 17 20 24 3 7 3 4 5 6 0 1 2 17 20 24 3 7 10 14 6 0 1 2 3 4 5 24 3 7 10 14 17 20 2 3 4 5 6 0 1 7 10 14 17 20 24 3 5 6 0 1 2 3 4 14 17 20 24 3 7 10 1 2 3 4 5 6 0 20 24 3 7 10 14 17 4 5 6 0 1 2 3

7x column+1x row coord.+1+102 = Third panmagic 7x7 square

 22 51 73 102 124 146 175 124 153 175 204 226 248 277 74 103 125 147 169 23 52 176 205 227 249 271 125 154 126 141 170 24 53 75 104 228 243 272 126 155 177 206 171 25 54 76 105 120 142 273 127 156 178 207 222 244 55 77 99 121 143 172 26 157 179 201 223 245 274 128 100 122 144 173 27 56 71 202 224 246 275 129 158 173 145 174 28 50 72 101 123 247 276 130 152 174 203 225

Column coordinates fourth square       Row coordinates fourth square

 1 6 8 12 19 22 27 0 1 2 3 4 5 6 8 12 19 22 27 1 6 3 4 5 6 0 1 2 19 22 27 1 6 8 12 6 0 1 2 3 4 5 27 1 6 8 12 19 22 2 3 4 5 6 0 1 6 8 12 19 22 27 1 5 6 0 1 2 3 4 12 19 22 27 1 6 8 1 2 3 4 5 6 0 22 27 1 6 8 12 19 4 5 6 0 1 2 3

7x column+1x row coord.+1+102 = Fourth panmagic 7x7 square

 8 44 59 88 138 160 196 110 146 161 190 240 262 298 60 89 139 161 190 9 45 162 191 241 263 292 111 147 140 155 191 10 46 61 90 242 257 293 112 148 163 192 192 11 47 62 91 134 156 294 113 149 164 193 236 258 48 63 85 135 157 193 12 150 165 187 237 259 295 114 86 136 158 194 13 49 57 188 238 260 296 115 151 159 159 195 14 43 58 87 137 261 297 116 145 160 189 239

Put the first and second panmagic 7x7 square on top and the third and fourth panmagic 7x7 square at the bottom. That give the following sum totals of the rows, the columns and the diagonals:

 2807 2807 2807 2807 2807 2807 2807 2807 2807 2807 2807