3 kyu
Make a spiral
59 of 15,031Bugari
Description:
Your task, is to create a NxN spiral with a given size
.
For example, spiral with size 5 should look like this:
00000
....0
000.0
0...0
00000
and with the size 10:
0000000000
.........0
00000000.0
0......0.0
0.0000.0.0
0.0..0.0.0
0.0....0.0
0.000000.0
0........0
0000000000
Return value should contain array of arrays, of 0
and 1
, with the first row being composed of 1
s.
For example for given size 5
result should be:
[[1,1,1,1,1],[0,0,0,0,1],[1,1,1,0,1],[1,0,0,0,1],[1,1,1,1,1]]
Because of the edge-cases for tiny spirals, the size will be at least 5.
General rule-of-a-thumb is, that the snake made with '1' cannot touch to itself.
Algorithms
Arrays
Logic
Similar Kata:
Stats:
Created | Apr 16, 2014 |
Published | Apr 16, 2014 |
Warriors Trained | 44095 |
Total Skips | 10212 |
Total Code Submissions | 97885 |
Total Times Completed | 15031 |
CoffeeScript Completions | 59 |
JavaScript Completions | 4048 |
Python Completions | 6691 |
Ruby Completions | 430 |
Haskell Completions | 305 |
Swift Completions | 187 |
Java Completions | 1636 |
Julia Completions | 36 |
Rust Completions | 388 |
C# Completions | 856 |
COBOL Completions | 6 |
C Completions | 467 |
Go Completions | 219 |
Kotlin Completions | 100 |
Lua Completions | 59 |
D Completions | 7 |
Total Stars | 1776 |
% of votes with a positive feedback rating | 91% of 1919 |
Total "Very Satisfied" Votes | 1647 |
Total "Somewhat Satisfied" Votes | 212 |
Total "Not Satisfied" Votes | 60 |