13
1
Consider this spiral
###########
#
# #######
# # #
# # ### #
# # # # #
# # # # #
# # # #
# ##### #
# #
#########
Starting in the centre:
- The first line (upwards) has 3 characters.
- The second line has the same number of characters (3)
- Next, we add two chars (5) for the next two sides.
- This pattern continues, two sides the same length then increase the length by 2.
I want to generate this spiral for N lines.
- Write in any language.
- The input/argument, etc. is the number of lines in your spiral.
- Each line starts with the ending character of the previous line in the direction 90 degrees clockwise of the previous line.
- I don't care how much whitespace is before or after each line, as long as the elements of the spiral line up.
- Output text to draw the spiral with any non-whitespace character you choose.
- Attempt to do this in the smallest number of bytes.
Test cases (using a hash as output):
N = 1
#
#
#
N = 2
###
#
#
N = 3
###
# #
# #
#
#
N = 10
###########
#
# #######
# # #
# # ### #
# # # # #
# # # # #
# # # #
# ##### #
# #
#########
@Shaggy "Output text to draw the spiral with any non-whitespace character you choose." Yep, whatever you like. – AJFaraday – 2018-06-26T11:09:11.207
3Related 1; Related 2. – Kevin Cruijssen – 2018-06-26T11:10:30.427
3The initial image has an
*
instead of#
. Expected? – Wernisch – 2018-06-26T11:56:04.133@Wernisch It was intended to be a helpful starting point, but I suppose it's misleading. You can use any character you like. – AJFaraday – 2018-06-26T12:36:28.930