Last active
December 18, 2018 10:54
-
-
Save lauslim12/520eb5a41e60fe25788aceb859a076f7 to your computer and use it in GitHub Desktop.
Simple christmas tree with Ruby.
This file contains hidden or 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
# 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