29
1
Given the spiral of size S
and the step N
, output the "square" S*S
spiral having N
asterisks, built from the outer to inner radius clockwise.
Test cases (examples) below.
Input:
4 3
Output:
***
Input:
4 6
Output:
**** * *
Input:
4 11
Output:
**** * * * ****
Input:
6 18
Output:
****** * * * * * * ******
Input:
6 22
Output:
****** *** * * * * * * * ******
Input:
6 27
Output:
****** ****** * ** * ** * ** ******
Input:
1 1
Output:
*
It's not necessary to handle the cases when:
provided
N
asterisks can't "fit" in the spiral of givenS*S
dimensions.either
N
orS
is zero.
The challenge is code-golf, shortest bytes answer wins, any languages can be used.
Your output may have as many trailing (but not leading) spaces/newlines as you wish.
Can we have trailing spaces/newlines? – user202729 – 2018-04-01T15:43:42.563
2I'd call
S
size (or at least diameter) rather than radius – Luis Mendo – 2018-04-01T15:58:53.410@Luis fair point! – nicael – 2018-04-01T16:03:31.590
@LuisMendo Or side length. – Erik the Outgolfer – 2018-04-01T16:48:45.203
3Dear friends, please vote on answers also, not just question. It's easy to make this challenge. Providing an answer to it is (I think) definitely more difficult. – nicael – 2018-04-01T19:07:28.030
2Only you think so. Writing a well-received and clear challenge is very difficult. (just look at the comment thread right here, there are some suggestions after the challenge had been posted) – user202729 – 2018-04-02T02:18:44.493
related: https://codegolf.stackexchange.com/questions/89725/alphabet-spiral
– Titus – 2018-04-02T05:17:10.197@Luis, lol, i havent noticed that instead of replacing the word radius with size, I replaced spiral with size xD funny that nobody else noticed – nicael – 2018-04-03T16:09:31.870
@nicael TBH I did, but I didn't want to be boring :-) – Luis Mendo – 2018-04-03T16:26:24.703