Home /
Expert Answers /
Computer Science /
problem-8-dragon-curve-the-instructions-for-drawing-a-dragon-curve-are-strings-of-the-character-pa628
(Solved):
Problem 8. (Dragon Curve) The instructions for drawing a dragon curve are strings of the character ...
Problem 8. (Dragon Curve) The instructions for drawing a dragon curve are strings of the characters \( F, L \), and \( R \), where \( F \) means "draw a line while moving 1 unit forward", \( L \) means "turn left", and \( R \) means "turn right". The key to solving this problem is to note that a curve of order \( n \) is a curve of order \( n-1 \) followed by an \( L \) followed by a curve of order \( n-1 \) traversed in reverse order, replacing \( L \) with \( R \) and \( R \) with \( L \). Write a program called dragon_curve.py that accepts \( n \) (int) as command-line argument, and writes to standard output the instructions for drawing a dragon curve of order \( n \). Directions: - Set dragon and nogard to the string "F". - Repeat for each \( i \in[1, n] \) : - Exchange dragon and nogard with dragon "L" nogard and dragon "R" nogard. - Write dragon (dragon curve of order \( n \) ).