Created
January 27, 2015 21:04
-
-
Save anonymous/972ae0b6896c1b6e3beb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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