Skip to content

Instantly share code, notes, and snippets.

Created January 27, 2015 21:04
Show Gist options
  • Save anonymous/972ae0b6896c1b6e3beb to your computer and use it in GitHub Desktop.
Save anonymous/972ae0b6896c1b6e3beb to your computer and use it in GitHub Desktop.
# Invoke as follow
# $ ruby build.rb x
# Where $ is your bash prompt and x is the glass ceiling you want to build.
def build(n)
unless (n-1) < 0
build(n-1)
end
unless (n-2) < 0
destroy(n-2)
end
puts "Build #{n}"
unless (n-2) < 0
build(n-2)
end
end
def destroy(n)
unless (n-2) < 0
destroy(n-2)
end
puts "Destroy #{n}"
unless (n-2) < 0
build(n-2)
end
unless (n-1) < 0
destroy(n-1)
end
end
def main(args)
build(args[0].to_i)
end
main(ARGV)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment