Skip to content

Instantly share code, notes, and snippets.

@gor-sg
Created October 29, 2015 10:45
Show Gist options
  • Select an option

  • Save gor-sg/e6e9b7b21c03f20910c7 to your computer and use it in GitHub Desktop.

Select an option

Save gor-sg/e6e9b7b21c03f20910c7 to your computer and use it in GitHub Desktop.
christmas tree
n = 22; m = 2; (1..n).select(&:odd?).each{ |i| p (" " * ((n - 1)/2 - i/2) + "x" * i) }; m.times{ |x| p (' ' * ((n - 1)/2) + 'x') }
" x"
" xxx"
" xxxxx"
" xxxxxxx"
" xxxxxxxxx"
" xxxxxxxxxxx"
" xxxxxxxxxxxxx"
" xxxxxxxxxxxxxxx"
" xxxxxxxxxxxxxxxxx"
" xxxxxxxxxxxxxxxxxxx"
"xxxxxxxxxxxxxxxxxxxxx"
" x"
" x"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment