Back
Close

The squared spiral

Statement

 Goal

The goal is to draw a spiral of 1 embedded in a square filled with 0.
The spiral starts with the square center, then going up and always turn right.
N an odd number which is the square side length.

Example for N=3
011
010
000

Example with N=7
0111111
0100000
0101110
0101010
0100010
0111110
0000000
Input
Line 1 : An odd integer N for the square length
Output
N next lines : N lines of characters 1 or 0
Constraints
N = 2k+1 where 0 ≤ k ≤ 15
Example
Input
3
Output
011
010
000

Game modes
Fastest, Shortest

Test cases
3 Test
Input
3
Output
011 010 000

3 Validator
Input
3
Output
011 010 000

7 Test
Input
7
Output
0111111 0100000 0101110 0101010 0100010 0111110 0000000

7 Validator
Input
7
Output
0111111 0100000 0101110 0101010 0100010 0111110 0000000

1 Test
Input
1
Output
1

1 Validator
Input
1
Output
1

11 Test
Input
11
Output
01111111111 01000000000 01011111110 01010000010 01010111010 01010101010 01010001010 01011111010 01000000010 01111111110 00000000000

13 Validator
Input
13
Output
1000000000000 1011111111111 1010000000001 1010111111101 1010100000101 1010101110101 1010101010101 1010100010101 1010111110101 1010000000101 1011111111101 1000000000001 1111111111111

17 Test
Input
17
Output
10000000000000000 10111111111111111 10100000000000001 10101111111111101 10101000000000101 10101011111110101 10101010000010101 10101010111010101 10101010101010101 10101010001010101 10101011111010101 10101000000010101 10101111111110101 10100000000000101 10111111111111101 10000000000000001 11111111111111111

29 Validator
Input
29
Output
10000000000000000000000000000 10111111111111111111111111111 10100000000000000000000000001 10101111111111111111111111101 10101000000000000000000000101 10101011111111111111111110101 10101010000000000000000010101 10101010111111111111111010101 10101010100000000000001010101 10101010101111111111101010101 10101010101000000000101010101 10101010101011111110101010101 10101010101010000010101010101 10101010101010111010101010101 10101010101010101010101010101 10101010101010001010101010101 10101010101011111010101010101 10101010101000000010101010101 10101010101111111110101010101 10101010100000000000101010101 10101010111111111111101010101 10101010000000000000001010101 10101011111111111111111010101 10101000000000000000000010101 10101111111111111111111110101 10100000000000000000000000101 10111111111111111111111111101 10000000000000000000000000001 11111111111111111111111111111

27 Test
Input
27
Output
011111111111111111111111111 010000000000000000000000000 010111111111111111111111110 010100000000000000000000010 010101111111111111111111010 010101000000000000000001010 010101011111111111111101010 010101010000000000000101010 010101010111111111110101010 010101010100000000010101010 010101010101111111010101010 010101010101000001010101010 010101010101011101010101010 010101010101010101010101010 010101010101000101010101010 010101010101111101010101010 010101010100000001010101010 010101010111111111010101010 010101010000000000010101010 010101011111111111110101010 010101000000000000000101010 010101111111111111111101010 010100000000000000000001010 010111111111111111111111010 010000000000000000000000010 011111111111111111111111110 000000000000000000000000000

31 Validator
Input
31
Output
0111111111111111111111111111111 0100000000000000000000000000000 0101111111111111111111111111110 0101000000000000000000000000010 0101011111111111111111111111010 0101010000000000000000000001010 0101010111111111111111111101010 0101010100000000000000000101010 0101010101111111111111110101010 0101010101000000000000010101010 0101010101011111111111010101010 0101010101010000000001010101010 0101010101010111111101010101010 0101010101010100000101010101010 0101010101010101110101010101010 0101010101010101010101010101010 0101010101010100010101010101010 0101010101010111110101010101010 0101010101010000000101010101010 0101010101011111111101010101010 0101010101000000000001010101010 0101010101111111111111010101010 0101010100000000000000010101010 0101010111111111111111110101010 0101010000000000000000000101010 0101011111111111111111111101010 0101000000000000000000000001010 0101111111111111111111111111010 0100000000000000000000000000010 0111111111111111111111111111110 0000000000000000000000000000000

Solution language

Solution

Stub generator input