Submit an Entry

To enter the challenge, you need to signup or login.

This Challenge's Best Entries [View All]

(View the Overall | Perl | PHP | Python | Ruby

Rank User Size Language Score [?]
1st primo 104 Perl 10,000 (v119)
2nd flagitious 112 Ruby 9,285 (v27)
3rd ySas 114 Perl 9,122 (v33)
4th kik 117 Ruby 8,888 (v20)
5th mame 117 Ruby 8,888 (v13)
6th irori 119 Ruby 8,739 (v16)
7th yvl 120 Ruby 8,666 (v7)
8th J-_-L 120 Ruby 8,666 (v4)
9th ksk 121 Ruby 8,595 (v9)
10th terjek 122 Perl 8,524 (v5)

See who is active in this challenge →

Oblongular Number Spirals

(Challenge added over 6 years 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.