Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/brandymint/test
Coder test
https://github.com/brandymint/test
Last synced: about 2 months ago
JSON representation
Coder test
- Host: GitHub
- URL: https://github.com/brandymint/test
- Owner: BrandyMint
- Created: 2012-11-21T12:59:29.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2012-12-16T08:15:36.000Z (about 12 years ago)
- Last Synced: 2023-03-10T22:28:58.291Z (almost 2 years ago)
- Language: Ruby
- Homepage:
- Size: 145 KB
- Stars: 0
- Watchers: 19
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# The issue
> Write a program in Ruby that takes one command line argument (referred to going forward as n).
> If n is not a perfect square print an appropriate error message and exit. If n is a perfect
> square then create a sequence from 1 to n and build a matrix from the sequence by walking
> in counter-clockwise spiral order. Examples below illustrate this for n=1,4,9,16 but your
> solution should work for any n that is a perfect square. Once you have built the matrix print
> it, ensuring even column widths as in examples below and then exit.
>
> Input: 1
> Output: 1
>
> Input: 4
> Output: 4 3
> 1 2
>
> Input: 9
> Output: 5 4 3
> 6 1 2
> 7 8 9
>
> Input: 16
> Output: 16 15 14 13
> 5 4 3 12
> 6 1 2 11
> 7 8 9 10