Python Code Example
Here is a short Python script to implement method 2 for generating the symbolic code for the nth iteration of the Lévy dragon curve.
n = input("n = ")
b = []
code = ''
turn = ['R','S','L','B']
for k in range(0,2**n):
b += [0]
for k in range(1,2**(n-1)):
b[2*k] = (b[k] + 1) % 4
for k in range(1,2**n):
code = code +' '+ turn[int(b[k])]
print(code[1:])
