Oblongular Number Spirals
(Challenge added 666 days ago.)
Oblongular *is* a word ...
The Problem
This challenge involves you having to create a number spiral such as :
1 2 3 10 11 4 9 12 5 8 7 6
Note how the numbers spiral in clockwise towards the centre. Here's a larger example :
1 2 3 4 5 18 19 20 21 6 17 28 29 22 7 16 27 30 23 8 15 26 25 24 9 14 13 12 11 10
Part of the fun of the challenge is to work out how to fill in the spiral, so I'll leave you with these two examples, and the random examples you can generate below.
More Information
- The size of your spiral will be given to your code on stdin as two space-separated numbers. The first number is the width of the spiral and the second number is the height.
- Your code will be run three times for each submission you make. You will need to pass all three runs for your code to be deemed successful.
- Both the width and height of the spiral will be in the range 1-30 inclusive. There will be no link between the width and height.
- Note that the numbers are right-aligned and padded with spaces in columns which are as wide as the widest number in the spiral. Each column is then separated by a single space.
More Examples
Click here to see examples of the input and the expected output. Refresh the page to see different examples.
