Introduction
The Dragon's Curve is a fractal curve that notably appears on section title pages of the Jurassic Park novel.
It can very simply be described as a process of folding a paper strip, as explained in the Wikipedia article about this curve.
The first few iterations of the generation of this curve look like this (credits to Wikipedia for the image):
The challenge
Write a program or function that, given an integer n as input, outputs the n-th iteration of the dragon curve as ASCII art using only the symbols _
and |
- You have to output the figure using only
|
,_
and spaces. You may not output the curve as a plot or anything else. - You can take the input as a program argument, in STDIN or as a function parameter.
- Inputs will always be an integer >= 0. Your program should work for reasonable values of inputs, 12 being the highest in the test cases offered.
The first iterations shall look like this
Iteration 0 is
_
Iteration 1 is
_|
Iteration 2 is
|_ _|
One trailing line at the end is ok. No trailing spaces allowed besides filling the line up to the rightmost character in the curve
No standard loopholes abuse as usual
Test Cases
- Input
0
Output
_
- Input
3
Output
_
|_| |_
_|
- Input
5
Output
_ _
|_|_| |_
_ _| _|
|_|_|_
|_|_|
|_
_|
|_|
- Input
10
Output
_ _
_|_| _|_|
|_|_ _|_|_ _
_|_|_| |_| |_|_|
_ |_|_|_ |_
_|_| _| |_| _|
|_|_ _|_ |_|
_|_|_|_|_|_
|_| |_|_|_|_|_
_|_|_| |_|
|_| |_
_|_ _ _ _ _ _ _
_ |_|_|_|_|_|_|_ |_|_|_|_ |_|_|_|_
_|_| _|_|_|_|_| |_| _ _|_| |_| _ _|_| |_|
|_|_ _|_|_|_|_|_ |_|_|_|_ |_|_|_|_
_|_|_|_|_|_|_|_|_|_ _ _|_|_|_|_ _ _|_|_|_|_ _ _
|_| |_|_|_| |_|_|_| |_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_
_|_| _|_| _|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_| |_|
|_| |_| |_| |_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_
_|_|_|_|_|_|_|_|_|_|_| |_| |_|_|_|_
_ |_|_|_|_|_|_|_|_|_|_|_ |_|_|_|_
_|_| _|_|_|_|_|_|_|_|_| |_| _ _|_| |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|_|_|_|_
_|_|_| |_| _ _|_|_|_|_|_|_|_|_|_|_| _|_| _|_| _ _|_|_| _|_| _|_|_|_|_| |_|
|_| |_ |_|_|_|_|_|_|_|_|_|_|_|_|_ _ |_| |_| |_|_|_|_|_ _|_|_ _|_|_|_|_|_
_|_ _ _ _ _ |_|_|_|_|_|_|_|_|_|_|_|_|_|_| |_| |_| |_|_|_|_|_| |_| |_|_|_|_
_ |_|_|_|_|_|_|_ |_|_|_|_ |_|_|_|_|_|_|_|_|_|_| |_|_ |_|_|_|_ |_|_|_|_
_|_| _|_|_|_|_| |_| _ _|_| |_| _ _|_|_|_|_|_|_|_|_| _|_| _ _|_| |_| _ _|_| |_|
|_|_ _|_|_|_|_|_ |_|_|_|_ |_|_|_|_|_|_|_|_|_|_|_ |_| |_|_|_|_ |_|_|_|_
_|_|_|_|_|_|_|_|_|_ _ _|_|_|_|_ _ _|_|_|_|_|_|_|_|_|_|_| |_| |_| |_| |_|
|_| |_|_|_| |_|_|_| |_|_|_|_|_|_|_|_|_|_|_| |_|_|_| |_|_|_|_|_|_ _
_|_| _|_| _|_|_|_|_|_|_|_|_|_| _|_| _|_|_|_|_|_|_|_|
|_| |_| |_| |_|_|_|_|_|_|_|_ |_| |_| |_|_|_|_|_|_ _
_|_|_|_|_|_|_|_| _|_|_|_|_|_|_|_|
_ |_|_|_|_|_| |_|_ _ |_|_|_|_|_| |_|_
_|_| _|_|_|_| _|_| _|_| _|_|_|_| _|_|
|_|_ _|_|_|_|_ |_| |_|_ _|_|_|_|_ |_|
_|_|_|_|_|_|_|_| _|_|_|_|_|_|_|_|
|_| |_|_|_| |_|_ |_| |_|_|_| |_|_
_|_| _|_| _|_| _|_|
|_| |_| |_| |_|
Scoring
This is code-golf, so the shortest program in bytes wins.