Code Golf Christmas Edition: How to print out a Christmas tree of height N
Posted
by TheSoftwareJedi
on Stack Overflow
See other posts from Stack Overflow
or by TheSoftwareJedi
Published on 2008-12-25T12:48:11Z
Indexed on
2010/04/30
23:17 UTC
Read the original article
Hit count: 410
Given a number N, how can I print out a Christmas tree of height N using the least number of code characters? N is assumed constrained to a min val of 3, and a max val of 30 (bounds and error checking are not necessary). N is given as the one and only command line argument to your program or script.
All languages appreciated, if you see a language already implemented and you can make it shorter, edit if possible - comment otherwise and hope someone cleans up the mess. Include newlines and whitespace for clarity, but don't include them in the character count.
A Christmas tree is generated as such, with its "trunk" consisting of only a centered "*"
N = 3:
*
***
*****
*
N = 4:
*
***
*****
*******
*
N = 5:
*
***
*****
*******
*********
*
N defines the height of the branches not including the one line trunk.
Merry Christmas SO!
© Stack Overflow or respective owner