Skip to main content
Tweeted twitter.com/StackCodeGolf/status/1487259646561824769
Became Hot Network Question
added 6 characters in body
Source Link

Given an integer \$N\$, you must print a \$N*N\$\$N\times N\$ integer involute with the numbers increasing in a clockwise rotation. You can start with either 0 or 1 at the top left, increasing as you move towards the centre.

Examples

Input => 1
Output => 
0

Input => 2
Output => 
0 1
3 2

Input => 5
Output => 
 0  1  2  3 4
15 16 17 18 5
14 23 24 19 6
13 22 21 20 7
12 11 10  9 8 

Input => 10
Output => 
 0  1  2  3  4  5  6  7  8  9
35 36 37 38 39 40 41 42 43 10
34 63 64 65 66 67 68 69 44 11
33 62 83 84 85 86 87 70 45 12
32 61 82 95 96 97 88 71 46 13
31 60 81 94 99 98 89 72 47 14
30 59 80 93 92 91 90 73 48 15
29 58 79 78 77 76 75 74 49 16
28 57 56 55 54 53 52 51 50 17
27 26 25 24 23 22 21 20 19 18

You may output a 2 dimensional array, or a grid of numbers.

Challenge inspired by Article by Eugene McDonnell

This is so the goal is to minimize your source code with answers being scored in bytes.

Given an integer \$N\$, you must print a \$N*N\$ integer involute with the numbers increasing in a clockwise rotation. You can start with either 0 or 1 at the top left, increasing as you move towards the centre.

Examples

Input => 1
Output => 
0

Input => 2
Output => 
0 1
3 2

Input => 5
Output => 
 0  1  2  3 4
15 16 17 18 5
14 23 24 19 6
13 22 21 20 7
12 11 10  9 8 

Input => 10
Output => 
 0  1  2  3  4  5  6  7  8  9
35 36 37 38 39 40 41 42 43 10
34 63 64 65 66 67 68 69 44 11
33 62 83 84 85 86 87 70 45 12
32 61 82 95 96 97 88 71 46 13
31 60 81 94 99 98 89 72 47 14
30 59 80 93 92 91 90 73 48 15
29 58 79 78 77 76 75 74 49 16
28 57 56 55 54 53 52 51 50 17
27 26 25 24 23 22 21 20 19 18

You may output a 2 dimensional array, or a grid of numbers.

Challenge inspired by Article by Eugene McDonnell

This is so the goal is to minimize your source code with answers being scored in bytes.

Given an integer \$N\$, you must print a \$N\times N\$ integer involute with the numbers increasing in a clockwise rotation. You can start with either 0 or 1 at the top left, increasing as you move towards the centre.

Examples

Input => 1
Output => 
0

Input => 2
Output => 
0 1
3 2

Input => 5
Output => 
 0  1  2  3 4
15 16 17 18 5
14 23 24 19 6
13 22 21 20 7
12 11 10  9 8 

Input => 10
Output => 
 0  1  2  3  4  5  6  7  8  9
35 36 37 38 39 40 41 42 43 10
34 63 64 65 66 67 68 69 44 11
33 62 83 84 85 86 87 70 45 12
32 61 82 95 96 97 88 71 46 13
31 60 81 94 99 98 89 72 47 14
30 59 80 93 92 91 90 73 48 15
29 58 79 78 77 76 75 74 49 16
28 57 56 55 54 53 52 51 50 17
27 26 25 24 23 22 21 20 19 18

You may output a 2 dimensional array, or a grid of numbers.

Challenge inspired by Article by Eugene McDonnell

This is so the goal is to minimize your source code with answers being scored in bytes.

deleted 1 character in body
Source Link
Cool guy
  • 441
  • 3
  • 9

Given an integer \$N\$, you must print a \$N*N\$ integer involute with the numbers increasing in a clockwise rotation. You can start with either 0 or 1 at the top rightleft, increasing as you move towards the centre.

Examples

Input => 1
Output => 
0

Input => 2
Output => 
0 1
3 2

Input => 5
Output => 
 0  1  2  3 4
15 16 17 18 5
14 23 24 19 6
13 22 21 20 7
12 11 10  9 8 

Input => 10
Output => 
 0  1  2  3  4  5  6  7  8  9
35 36 37 38 39 40 41 42 43 10
34 63 64 65 66 67 68 69 44 11
33 62 83 84 85 86 87 70 45 12
32 61 82 95 96 97 88 71 46 13
31 60 81 94 99 98 89 72 47 14
30 59 80 93 92 91 90 73 48 15
29 58 79 78 77 76 75 74 49 16
28 57 56 55 54 53 52 51 50 17
27 26 25 24 23 22 21 20 19 18

You may output a 2 dimensional array, or a grid of numbers.

Challenge inspired by Article by Eugene McDonnell

This is so the goal is to minimize your source code with answers being scored in bytes.

Given an integer \$N\$, you must print a \$N*N\$ integer involute with the numbers increasing in a clockwise rotation. You can start with either 0 or 1 at the top right, increasing as you move towards the centre.

Examples

Input => 1
Output => 
0

Input => 2
Output => 
0 1
3 2

Input => 5
Output => 
 0  1  2  3 4
15 16 17 18 5
14 23 24 19 6
13 22 21 20 7
12 11 10  9 8 

Input => 10
Output => 
 0  1  2  3  4  5  6  7  8  9
35 36 37 38 39 40 41 42 43 10
34 63 64 65 66 67 68 69 44 11
33 62 83 84 85 86 87 70 45 12
32 61 82 95 96 97 88 71 46 13
31 60 81 94 99 98 89 72 47 14
30 59 80 93 92 91 90 73 48 15
29 58 79 78 77 76 75 74 49 16
28 57 56 55 54 53 52 51 50 17
27 26 25 24 23 22 21 20 19 18

You may output a 2 dimensional array, or a grid of numbers.

Challenge inspired by Article by Eugene McDonnell

This is so the goal is to minimize your source code with answers being scored in bytes.

Given an integer \$N\$, you must print a \$N*N\$ integer involute with the numbers increasing in a clockwise rotation. You can start with either 0 or 1 at the top left, increasing as you move towards the centre.

Examples

Input => 1
Output => 
0

Input => 2
Output => 
0 1
3 2

Input => 5
Output => 
 0  1  2  3 4
15 16 17 18 5
14 23 24 19 6
13 22 21 20 7
12 11 10  9 8 

Input => 10
Output => 
 0  1  2  3  4  5  6  7  8  9
35 36 37 38 39 40 41 42 43 10
34 63 64 65 66 67 68 69 44 11
33 62 83 84 85 86 87 70 45 12
32 61 82 95 96 97 88 71 46 13
31 60 81 94 99 98 89 72 47 14
30 59 80 93 92 91 90 73 48 15
29 58 79 78 77 76 75 74 49 16
28 57 56 55 54 53 52 51 50 17
27 26 25 24 23 22 21 20 19 18

You may output a 2 dimensional array, or a grid of numbers.

Challenge inspired by Article by Eugene McDonnell

This is so the goal is to minimize your source code with answers being scored in bytes.

Source Link
Cool guy
  • 441
  • 3
  • 9

Print a NxN integer involute

Given an integer \$N\$, you must print a \$N*N\$ integer involute with the numbers increasing in a clockwise rotation. You can start with either 0 or 1 at the top right, increasing as you move towards the centre.

Examples

Input => 1
Output => 
0

Input => 2
Output => 
0 1
3 2

Input => 5
Output => 
 0  1  2  3 4
15 16 17 18 5
14 23 24 19 6
13 22 21 20 7
12 11 10  9 8 

Input => 10
Output => 
 0  1  2  3  4  5  6  7  8  9
35 36 37 38 39 40 41 42 43 10
34 63 64 65 66 67 68 69 44 11
33 62 83 84 85 86 87 70 45 12
32 61 82 95 96 97 88 71 46 13
31 60 81 94 99 98 89 72 47 14
30 59 80 93 92 91 90 73 48 15
29 58 79 78 77 76 75 74 49 16
28 57 56 55 54 53 52 51 50 17
27 26 25 24 23 22 21 20 19 18

You may output a 2 dimensional array, or a grid of numbers.

Challenge inspired by Article by Eugene McDonnell

This is so the goal is to minimize your source code with answers being scored in bytes.