Your task is to write a program that prints “spirals” of size , as it is shown in the examples.
The input consists of a sequence of natural numbers ended with zero.
For each , your program must print a spiral of size . Notice that in the row of the bottom and the column on the rigth there only are |’X’|s. Print a line in white after each spiral.
Although it is not essential use a matrix to solve this problem, do it for simplicity.
Salvador Roura (en: Carlos Molina)
© Jutge.org, 2006–2025.
Input
4 6 7 0
Output
.XXX .X.X ...X XXXX .XXXXX .X...X .X.X.X .XXX.X .....X XXXXXX .XXXXXX .X....X .X.XX.X .X..X.X .XXXX.X ......X XXXXXXX