dragon1.py


Below is the syntax highlighted version of dragon1.py from §1.2 Built-in Types of Data.


#-----------------------------------------------------------------------
# dragon1.py
#-----------------------------------------------------------------------

import stdio

# Write to standard output the instructions for drawing a dragon curve
# of orders 0 through 5.

dragon0 = 'F'
nogard0 = 'F'
dragon1 = dragon0 + 'L' + nogard0
nogard1 = dragon0 + 'R' + nogard0
dragon2 = dragon1 + 'L' + nogard1
nogard2 = dragon1 + 'R' + nogard1
dragon3 = dragon2 + 'L' + nogard2
nogard3 = dragon2 + 'R' + nogard2
dragon4 = dragon3 + 'L' + nogard3
nogard4 = dragon3 + 'R' + nogard3
dragon5 = dragon4 + 'L' + nogard4

stdio.writeln(dragon0)
stdio.writeln(dragon1)
stdio.writeln(dragon2)
stdio.writeln(dragon3)
stdio.writeln(dragon4)
stdio.writeln(dragon5)

#-----------------------------------------------------------------------

# python dragon1.py     
# F
# FLF
# FLFLFRF
# FLFLFRFLFLFRFRF
# FLFLFRFLFLFRFRFLFLFLFRFRFLFRFRF
# FLFLFRFLFLFRFRFLFLFLFRFRFLFRFRFLFLFLFRFLFLFRFRFRFLFLFRFRFLFRFRF


Copyright © 2000–2015, Robert Sedgewick, Kevin Wayne, and Robert Dondero.
Last updated: Fri Oct 20 20:45:16 EDT 2017.