Create a gist now

Instantly share code, notes, and snippets.

A simple dragon curve algorithm
# Dragon Curve algorithm
# source:
# Use: ruby dragon_curve.rb [number of iterations]
str = "R"
ARGV[0].to_i.times do
nstr = str.reverse
for i in 0..nstr.length
if nstr[i] == 82
nstr[i] = "L"
elsif nstr[i] == 76
nstr[i] = "R"
str = str + "R" + nstr
puts str
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment