Skip to content

Instantly share code, notes, and snippets.

@lauslim12
Last active December 18, 2018 10:54
Show Gist options
  • Save lauslim12/520eb5a41e60fe25788aceb859a076f7 to your computer and use it in GitHub Desktop.
Save lauslim12/520eb5a41e60fe25788aceb859a076f7 to your computer and use it in GitHub Desktop.
Simple christmas tree with Ruby.
# n here is the 'row', or the whitespace.
# height is the height of the tree.
def tree(height)
height.times do |n|
print ' ' * (height - n)
puts "\033[32m*\033[0m" * (2 * n + 1)
end
4.times do
puts '#####'.center(41)
end
puts ''
puts "Merry Christmas!".center(43)
end
tree(20)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment