Dragon curves. Write a recursive Turtle client Dragon that draws dragon curves (see EXERCISE 1.2.35 and EXERCISE 1.5.9).
EXERCISE 1.2.35
Dragon curves. Write a program to print the instructions for drawing the dragon curves of order 0 through 5. The instructions are strings of F, L, and R characters, where F means “draw line while moving 1 unit forward,” L means “turn left,” and R means “turn right.” A dragon curve of order n is formed when you fold a strip of paper in half n times, then unfold to right angles. 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, and then to figure out a similar description for the reverse curve.
EXERCISE 1.5.9
Suppose that the file input.txt contains the two strings F and F. What does the following command do (see EXERCISE 1.2.35)?
%java Dragon
public class Dragon {public static void main(String[] args){String dragon = StdIn.readString();String nogard = StdIn.readString();StdOut.print(dragon + "L" + nogard);StdOut.print(" ");StdOut.print(dragon + "R" + nogard);StdOut.println() ;}}
EXERCISE 1.2.35
Dragon curves. Write a program to print the instructions for drawing the dragon curves of order 0 through 5. The instructions are strings of F, L, and R characters, where F means “draw line while moving 1 unit forward,” L means “turn left,” and R means “turn right.” A dragon curve of order n is formed when you fold a strip of paper in half n times, then unfold to right angles. 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, and then to figure out a similar description for the reverse curve.
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.