You can transform a 20x20 square with consecutive numbers into a most perfect magic 20x20 square in the following 5 steps. Swap each time 'yellow' and 'red':
+ | ~ | # | * | @ | @ | * | # | ~ | + | |||||||||||
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | |
21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | |
41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | |
61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | |
81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | |
101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | |
121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | |
141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | |
161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | |
181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | |
201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | |
221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | |
241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | |
261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | |
281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | |
301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | |
321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | |
341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | |
361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | |
381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | |
1 | 2 | 20 | 19 | 5 | 6 | 16 | 15 | 9 | 10 | 12 | 11 | 13 | 14 | 8 | 7 | 17 | 18 | 4 | 3 | |
21 | 22 | 40 | 39 | 25 | 26 | 36 | 35 | 29 | 30 | 32 | 31 | 33 | 34 | 28 | 27 | 37 | 38 | 24 | 23 | |
+ | 41 | 42 | 60 | 59 | 45 | 46 | 56 | 55 | 49 | 50 | 52 | 51 | 53 | 54 | 48 | 47 | 57 | 58 | 44 | 43 |
~ | 61 | 62 | 80 | 79 | 65 | 66 | 76 | 75 | 69 | 70 | 72 | 71 | 73 | 74 | 68 | 67 | 77 | 78 | 64 | 63 |
81 | 82 | 100 | 99 | 85 | 86 | 96 | 95 | 89 | 90 | 92 | 91 | 93 | 94 | 88 | 87 | 97 | 98 | 84 | 83 | |
101 | 102 | 120 | 119 | 105 | 106 | 116 | 115 | 109 | 110 | 112 | 111 | 113 | 114 | 108 | 107 | 117 | 118 | 104 | 103 | |
# | 121 | 122 | 140 | 139 | 125 | 126 | 136 | 135 | 129 | 130 | 132 | 131 | 133 | 134 | 128 | 127 | 137 | 138 | 124 | 123 |
* | 141 | 142 | 160 | 159 | 145 | 146 | 156 | 155 | 149 | 150 | 152 | 151 | 153 | 154 | 148 | 147 | 157 | 158 | 144 | 143 |
161 | 162 | 180 | 179 | 165 | 166 | 176 | 175 | 169 | 170 | 172 | 171 | 173 | 174 | 168 | 167 | 177 | 178 | 164 | 163 | |
181 | 182 | 200 | 199 | 185 | 186 | 196 | 195 | 189 | 190 | 192 | 191 | 193 | 194 | 188 | 187 | 197 | 198 | 184 | 183 | |
@ | 201 | 202 | 220 | 219 | 205 | 206 | 216 | 215 | 209 | 210 | 212 | 211 | 213 | 214 | 208 | 207 | 217 | 218 | 204 | 203 |
@ | 221 | 222 | 240 | 239 | 225 | 226 | 236 | 235 | 229 | 230 | 232 | 231 | 233 | 234 | 228 | 227 | 237 | 238 | 224 | 223 |
241 | 242 | 260 | 259 | 245 | 246 | 256 | 255 | 249 | 250 | 252 | 251 | 253 | 254 | 248 | 247 | 257 | 258 | 244 | 243 | |
261 | 262 | 280 | 279 | 265 | 266 | 276 | 275 | 269 | 270 | 272 | 271 | 273 | 274 | 268 | 267 | 277 | 278 | 264 | 263 | |
* | 281 | 282 | 300 | 299 | 285 | 286 | 296 | 295 | 289 | 290 | 292 | 291 | 293 | 294 | 288 | 287 | 297 | 298 | 284 | 283 |
# | 301 | 302 | 320 | 319 | 305 | 306 | 316 | 315 | 309 | 310 | 312 | 311 | 313 | 314 | 308 | 307 | 317 | 318 | 304 | 303 |
321 | 322 | 340 | 339 | 325 | 326 | 336 | 335 | 329 | 330 | 332 | 331 | 333 | 334 | 328 | 327 | 337 | 338 | 324 | 323 | |
341 | 342 | 360 | 359 | 345 | 346 | 356 | 355 | 349 | 350 | 352 | 351 | 353 | 354 | 348 | 347 | 357 | 358 | 344 | 343 | |
~ | 361 | 362 | 380 | 379 | 365 | 366 | 376 | 375 | 369 | 370 | 372 | 371 | 373 | 374 | 368 | 367 | 377 | 378 | 364 | 363 |
+ | 381 | 382 | 400 | 399 | 385 | 386 | 396 | 395 | 389 | 390 | 392 | 391 | 393 | 394 | 388 | 387 | 397 | 398 | 384 | 383 |
1 | 2 | 20 | 19 | 5 | 6 | 16 | 15 | 9 | 10 | 12 | 11 | 13 | 14 | 8 | 7 | 17 | 18 | 4 | 3 | |
21 | 22 | 40 | 39 | 25 | 26 | 36 | 35 | 29 | 30 | 32 | 31 | 33 | 34 | 28 | 27 | 37 | 38 | 24 | 23 | |
381 | 382 | 400 | 399 | 385 | 386 | 396 | 395 | 389 | 390 | 392 | 391 | 393 | 394 | 388 | 387 | 397 | 398 | 384 | 383 | |
361 | 362 | 380 | 379 | 365 | 366 | 376 | 375 | 369 | 370 | 372 | 371 | 373 | 374 | 368 | 367 | 377 | 378 | 364 | 363 | |
81 | 82 | 100 | 99 | 85 | 86 | 96 | 95 | 89 | 90 | 92 | 91 | 93 | 94 | 88 | 87 | 97 | 98 | 84 | 83 | |
101 | 102 | 120 | 119 | 105 | 106 | 116 | 115 | 109 | 110 | 112 | 111 | 113 | 114 | 108 | 107 | 117 | 118 | 104 | 103 | |
301 | 302 | 320 | 319 | 305 | 306 | 316 | 315 | 309 | 310 | 312 | 311 | 313 | 314 | 308 | 307 | 317 | 318 | 304 | 303 | |
281 | 282 | 300 | 299 | 285 | 286 | 296 | 295 | 289 | 290 | 292 | 291 | 293 | 294 | 288 | 287 | 297 | 298 | 284 | 283 | |
161 | 162 | 180 | 179 | 165 | 166 | 176 | 175 | 169 | 170 | 172 | 171 | 173 | 174 | 168 | 167 | 177 | 178 | 164 | 163 | |
181 | 182 | 200 | 199 | 185 | 186 | 196 | 195 | 189 | 190 | 192 | 191 | 193 | 194 | 188 | 187 | 197 | 198 | 184 | 183 | |
221 | 222 | 240 | 239 | 225 | 226 | 236 | 235 | 229 | 230 | 232 | 231 | 233 | 234 | 228 | 227 | 237 | 238 | 224 | 223 | |
201 | 202 | 220 | 219 | 205 | 206 | 216 | 215 | 209 | 210 | 212 | 211 | 213 | 214 | 208 | 207 | 217 | 218 | 204 | 203 | |
241 | 242 | 260 | 259 | 245 | 246 | 256 | 255 | 249 | 250 | 252 | 251 | 253 | 254 | 248 | 247 | 257 | 258 | 244 | 243 | |
261 | 262 | 280 | 279 | 265 | 266 | 276 | 275 | 269 | 270 | 272 | 271 | 273 | 274 | 268 | 267 | 277 | 278 | 264 | 263 | |
141 | 142 | 160 | 159 | 145 | 146 | 156 | 155 | 149 | 150 | 152 | 151 | 153 | 154 | 148 | 147 | 157 | 158 | 144 | 143 | |
121 | 122 | 140 | 139 | 125 | 126 | 136 | 135 | 129 | 130 | 132 | 131 | 133 | 134 | 128 | 127 | 137 | 138 | 124 | 123 | |
321 | 322 | 340 | 339 | 325 | 326 | 336 | 335 | 329 | 330 | 332 | 331 | 333 | 334 | 328 | 327 | 337 | 338 | 324 | 323 | |
341 | 342 | 360 | 359 | 345 | 346 | 356 | 355 | 349 | 350 | 352 | 351 | 353 | 354 | 348 | 347 | 357 | 358 | 344 | 343 | |
61 | 62 | 80 | 79 | 65 | 66 | 76 | 75 | 69 | 70 | 72 | 71 | 73 | 74 | 68 | 67 | 77 | 78 | 64 | 63 | |
41 | 42 | 60 | 59 | 45 | 46 | 56 | 55 | 49 | 50 | 52 | 51 | 53 | 54 | 48 | 47 | 57 | 58 | 44 | 43 | |
1 | 382 | 20 | 399 | 5 | 386 | 16 | 395 | 9 | 390 | 12 | 391 | 13 | 394 | 8 | 387 | 17 | 398 | 4 | 383 | |
21 | 22 | 40 | 39 | 25 | 26 | 36 | 35 | 29 | 30 | 32 | 31 | 33 | 34 | 28 | 27 | 37 | 38 | 24 | 23 | |
381 | 2 | 400 | 19 | 385 | 6 | 396 | 15 | 389 | 10 | 392 | 11 | 393 | 14 | 388 | 7 | 397 | 18 | 384 | 3 | |
361 | 362 | 380 | 379 | 365 | 366 | 376 | 375 | 369 | 370 | 372 | 371 | 373 | 374 | 368 | 367 | 377 | 378 | 364 | 363 | |
81 | 302 | 100 | 319 | 85 | 306 | 96 | 315 | 89 | 310 | 92 | 311 | 93 | 314 | 88 | 307 | 97 | 318 | 84 | 303 | |
101 | 102 | 120 | 119 | 105 | 106 | 116 | 115 | 109 | 110 | 112 | 111 | 113 | 114 | 108 | 107 | 117 | 118 | 104 | 103 | |
301 | 82 | 320 | 99 | 305 | 86 | 316 | 95 | 309 | 90 | 312 | 91 | 313 | 94 | 308 | 87 | 317 | 98 | 304 | 83 | |
281 | 282 | 300 | 299 | 285 | 286 | 296 | 295 | 289 | 290 | 292 | 291 | 293 | 294 | 288 | 287 | 297 | 298 | 284 | 283 | |
161 | 222 | 180 | 239 | 165 | 226 | 176 | 235 | 169 | 230 | 172 | 231 | 173 | 234 | 168 | 227 | 177 | 238 | 164 | 223 | |
181 | 182 | 200 | 199 | 185 | 186 | 196 | 195 | 189 | 190 | 192 | 191 | 193 | 194 | 188 | 187 | 197 | 198 | 184 | 183 | |
221 | 162 | 240 | 179 | 225 | 166 | 236 | 175 | 229 | 170 | 232 | 171 | 233 | 174 | 228 | 167 | 237 | 178 | 224 | 163 | |
201 | 202 | 220 | 219 | 205 | 206 | 216 | 215 | 209 | 210 | 212 | 211 | 213 | 214 | 208 | 207 | 217 | 218 | 204 | 203 | |
241 | 142 | 260 | 159 | 245 | 146 | 256 | 155 | 249 | 150 | 252 | 151 | 253 | 154 | 248 | 147 | 257 | 158 | 244 | 143 | |
261 | 262 | 280 | 279 | 265 | 266 | 276 | 275 | 269 | 270 | 272 | 271 | 273 | 274 | 268 | 267 | 277 | 278 | 264 | 263 | |
141 | 242 | 160 | 259 | 145 | 246 | 156 | 255 | 149 | 250 | 152 | 251 | 153 | 254 | 148 | 247 | 157 | 258 | 144 | 243 | |
121 | 122 | 140 | 139 | 125 | 126 | 136 | 135 | 129 | 130 | 132 | 131 | 133 | 134 | 128 | 127 | 137 | 138 | 124 | 123 | |
321 | 62 | 340 | 79 | 325 | 66 | 336 | 75 | 329 | 70 | 332 | 71 | 333 | 74 | 328 | 67 | 337 | 78 | 324 | 63 | |
341 | 342 | 360 | 359 | 345 | 346 | 356 | 355 | 349 | 350 | 352 | 351 | 353 | 354 | 348 | 347 | 357 | 358 | 344 | 343 | |
61 | 322 | 80 | 339 | 65 | 326 | 76 | 335 | 69 | 330 | 72 | 331 | 73 | 334 | 68 | 327 | 77 | 338 | 64 | 323 | |
41 | 42 | 60 | 59 | 45 | 46 | 56 | 55 | 49 | 50 | 52 | 51 | 53 | 54 | 48 | 47 | 57 | 58 | 44 | 43 | |
1 | 382 | 20 | 399 | 5 | 386 | 16 | 395 | 9 | 390 | 12 | 391 | 13 | 394 | 8 | 387 | 17 | 398 | 4 | 383 | |
40 | 39 | 21 | 22 | 36 | 35 | 25 | 26 | 32 | 31 | 29 | 30 | 28 | 27 | 33 | 34 | 24 | 23 | 37 | 38 | |
381 | 2 | 400 | 19 | 385 | 6 | 396 | 15 | 389 | 10 | 392 | 11 | 393 | 14 | 388 | 7 | 397 | 18 | 384 | 3 | |
380 | 379 | 361 | 362 | 376 | 375 | 365 | 366 | 372 | 371 | 369 | 370 | 368 | 367 | 373 | 374 | 364 | 363 | 377 | 378 | |
81 | 302 | 100 | 319 | 85 | 306 | 96 | 315 | 89 | 310 | 92 | 311 | 93 | 314 | 88 | 307 | 97 | 318 | 84 | 303 | |
120 | 119 | 101 | 102 | 116 | 115 | 105 | 106 | 112 | 111 | 109 | 110 | 108 | 107 | 113 | 114 | 104 | 103 | 117 | 118 | |
301 | 82 | 320 | 99 | 305 | 86 | 316 | 95 | 309 | 90 | 312 | 91 | 313 | 94 | 308 | 87 | 317 | 98 | 304 | 83 | |
300 | 299 | 281 | 282 | 296 | 295 | 285 | 286 | 292 | 291 | 289 | 290 | 288 | 287 | 293 | 294 | 284 | 283 | 297 | 298 | |
161 | 222 | 180 | 239 | 165 | 226 | 176 | 235 | 169 | 230 | 172 | 231 | 173 | 234 | 168 | 227 | 177 | 238 | 164 | 223 | |
200 | 199 | 181 | 182 | 196 | 195 | 185 | 186 | 192 | 191 | 189 | 190 | 188 | 187 | 193 | 194 | 184 | 183 | 197 | 198 | |
221 | 162 | 240 | 179 | 225 | 166 | 236 | 175 | 229 | 170 | 232 | 171 | 233 | 174 | 228 | 167 | 237 | 178 | 224 | 163 | |
220 | 219 | 201 | 202 | 216 | 215 | 205 | 206 | 212 | 211 | 209 | 210 | 208 | 207 | 213 | 214 | 204 | 203 | 217 | 218 | |
241 | 142 | 260 | 159 | 245 | 146 | 256 | 155 | 249 | 150 | 252 | 151 | 253 | 154 | 248 | 147 | 257 | 158 | 244 | 143 | |
280 | 279 | 261 | 262 | 276 | 275 | 265 | 266 | 272 | 271 | 269 | 270 | 268 | 267 | 273 | 274 | 264 | 263 | 277 | 278 | |
141 | 242 | 160 | 259 | 145 | 246 | 156 | 255 | 149 | 250 | 152 | 251 | 153 | 254 | 148 | 247 | 157 | 258 | 144 | 243 | |
140 | 139 | 121 | 122 | 136 | 135 | 125 | 126 | 132 | 131 | 129 | 130 | 128 | 127 | 133 | 134 | 124 | 123 | 137 | 138 | |
321 | 62 | 340 | 79 | 325 | 66 | 336 | 75 | 329 | 70 | 332 | 71 | 333 | 74 | 328 | 67 | 337 | 78 | 324 | 63 | |
360 | 359 | 341 | 342 | 356 | 355 | 345 | 346 | 352 | 351 | 349 | 350 | 348 | 347 | 353 | 354 | 344 | 343 | 357 | 358 | |
61 | 322 | 80 | 339 | 65 | 326 | 76 | 335 | 69 | 330 | 72 | 331 | 73 | 334 | 68 | 327 | 77 | 338 | 64 | 323 | |
60 | 59 | 41 | 42 | 56 | 55 | 45 | 46 | 52 | 51 | 49 | 50 | 48 | 47 | 53 | 54 | 44 | 43 | 57 | 58 | |
1 | 382 | 20 | 399 | 5 | 386 | 16 | 395 | 9 | 390 | 12 | 391 | 13 | 394 | 8 | 387 | 17 | 398 | 4 | 383 | |
380 | 39 | 361 | 22 | 376 | 35 | 365 | 26 | 372 | 31 | 369 | 30 | 368 | 27 | 373 | 34 | 364 | 23 | 377 | 38 | |
381 | 2 | 400 | 19 | 385 | 6 | 396 | 15 | 389 | 10 | 392 | 11 | 393 | 14 | 388 | 7 | 397 | 18 | 384 | 3 | |
40 | 379 | 21 | 362 | 36 | 375 | 25 | 366 | 32 | 371 | 29 | 370 | 28 | 367 | 33 | 374 | 24 | 363 | 37 | 378 | |
81 | 302 | 100 | 319 | 85 | 306 | 96 | 315 | 89 | 310 | 92 | 311 | 93 | 314 | 88 | 307 | 97 | 318 | 84 | 303 | |
300 | 119 | 281 | 102 | 296 | 115 | 285 | 106 | 292 | 111 | 289 | 110 | 288 | 107 | 293 | 114 | 284 | 103 | 297 | 118 | |
301 | 82 | 320 | 99 | 305 | 86 | 316 | 95 | 309 | 90 | 312 | 91 | 313 | 94 | 308 | 87 | 317 | 98 | 304 | 83 | |
120 | 299 | 101 | 282 | 116 | 295 | 105 | 286 | 112 | 291 | 109 | 290 | 108 | 287 | 113 | 294 | 104 | 283 | 117 | 298 | |
161 | 222 | 180 | 239 | 165 | 226 | 176 |