Spirals are interesting curves that appear everywhere throughout nature and mathematics. Given a number that is the largest length of the spiral arm, print a spiral going inwards, starting from the top left, to the top right, bottom right, bottom left, etc.
Input Specification
The only line of input is an integer .
Output Specification
Output a spiral using asterisks with the length of it's largest branch, (the branch at the top), being equal to the input. Start from the top left and move right, down, left, and up accordingly.
Note: The final asterisk at the centre of the spiral should not be directly next to another branch of the spiral, it must be a space apart from it.
Sample Input
6
Sample Output
* * * * * *
*
* * * * *
* * *
* *
* * * * * *
Sample Explanation
The number 6 is inputted. The line at the top is 6 asterisks long, then spirals inwards. Notice how the final asterisk in the centre is 1 space away from the line at the bottom, instead of next to it.
Sample Input 2
8
Sample Output 2
* * * * * * * *
*
* * * * * * *
* * *
* * * *
* * * * * *
* *
* * * * * * * *
Sample Explanation 2
The number 8 is inputted. The line at the top is 8 asterisks long and continues to spiral inward.
Sample Input 3
13
Sample Output 3
* * * * * * * * * * * * *
*
* * * * * * * * * * * *
* * *
* * * * * * * * * *
* * * * *
* * * * * * * *
* * * * * *
* * * * * * * * *
* * * *
* * * * * * * * * * *
* *
* * * * * * * * * * * * *
Sample Explanation 3
The number 13 is inputted. The line at the top is 13 asterisks long and continues to spiral inward.
Comments