+ 17
Challenge: make a spiral pattern
example: if user input the no. of rows =5 then output should be 1 2 3 4 5 16 17 18 19 6 15 24 25 20 7 14 23 22 21 8 13 12 11 10 9
17 ответов
+ 25
@Shruti
Thank you so much 🤗
for choosing my answer 😊
for TheBest !! 😆👍🤓
I'm glad you Like it !! 😉
+ 16
+ 11
https://www.sololearn.com/discuss/633313/?ref=app
+ 9
<script type="text/javascript">
spiralArray = function (edge) {
var arr = Array(edge),
x = 0, y = edge,
total = edge * edge--,
dx = 1, dy = 0,
i = 0, j = 0;
while (y) arr[--y] = [];
while (i < total) {
arr[y][x] = i++;
x += dx; y += dy;
if (++j == edge) {
if (dy < 0) {x++; y++; edge -= 2}
j = dx; dx = -dy; dy = j; j = 0;
}
}
return arr;
}
// T E S T:
arr = spiralArray(edge = 5);
for (y= 0; y < edge; y++) {
document.write(arr[y].join(" ")+"<br>");
}
</script>
+ 8
Change 3rd last line
var edge=prompt("Type your number");
+ 7
?
+ 7
+ 4
Here's mine:
https://code.sololearn.com/WoEZXsyny2IU/?ref=app
+ 4
from an earlier challenge
https://code.sololearn.com/cr5Ta5FcBrZ2/?ref=app
+ 4
https://code.sololearn.com/cDl89f5732Yo/?ref=app
+ 2
https://code.sololearn.com/cLdw7u9I3GvY/?ref=app
+ 2
My attempt.
https://code.sololearn.com/cG9mBPzt2fis/#cpp
+ 2
https://code.sololearn.com/c3iqKylTbk46/?ref=app