3 kyu
Make a spiral
6,780 of 15,227Bugari
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 | 44667 |
Total Skips | 10290 |
Total Code Submissions | 98680 |
Total Times Completed | 15227 |
CoffeeScript Completions | 60 |
JavaScript Completions | 4080 |
Python Completions | 6780 |
Ruby Completions | 437 |
Haskell Completions | 310 |
Swift Completions | 190 |
Java Completions | 1663 |
Julia Completions | 37 |
Rust Completions | 397 |
C# Completions | 867 |
COBOL Completions | 6 |
C Completions | 478 |
Go Completions | 229 |
Kotlin Completions | 104 |
Lua Completions | 62 |
D Completions | 8 |
Total Stars | 1790 |
% of votes with a positive feedback rating | 91% of 1935 |
Total "Very Satisfied" Votes | 1662 |
Total "Somewhat Satisfied" Votes | 212 |
Total "Not Satisfied" Votes | 61 |