Let's continue the fibonacci based challenges stream, here's the next one:
Task
Draw a Fibonacci spiral ascii-art of n segments where starting from the first term:
- each nth segment has a length of nth Fibonacci term.
- each segment is joined to the end of the previous, rotated by 90 degrees taking the end of previous segment as center of rotation.
- you can choose any printable ascii character chars to draw the spiral with, although the background must be spaces.
- You can draw the spiral in any orientation and turning clockwise or counterclockwise
- Leading/trailing whitespace is allowed within reason
Example
Let's explain it with the help of a visual example:
Beginning of segments are highlighted with an arrow character (> < ^ v) to indicate the direction.
End of segments highlighted with o
to indicate the pivot for the rotation of next segment.
Taking the first 9 terms [0,1,1,2,3,5,8,13,21] (the first term(0) doesn't draw anything) we draw clockwise.
o###################<o
#
#
#
#
#
#
#
o#<o #
v ^ #
# oo #
# #
# ^
o>######o
As you can see we start with one character(a segment of length 1) then add one to the right, then add two by rotating 90 degrees, then 3, then 5 .. and so on.
You can choose 0 or 1 indexing in the Fibonacci sequence, f(0) can draw anything or a single character, just be consistent on this.
Some more examples
n==1 (0-indexed) or n==0 (1-indexed)-> [1]
*
n==2 -> [1,1]
2 1 or 21
1 or 2 or 12
here we used '1' for the first segment and '2' for the second
n==3 ->[1,1,2]
1 or 12 or...
233 3
3
Rules
- This is code-golf: all the usual golfing rules apply.
- Either a function or a full program is fine.
- Input/output can be given by any convenient method.