93
15
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 minimum value of 3
, and a maximum value 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 White Spaces 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 PPCG!
With just 9 more characters you can give this function a name:
c=:[:((\:i.@#),}.)"1[:$&'*'"0[:>:0,~i.
– ephemient – 2009-07-06T20:45:51.75312What, do you guys use some sort of J documentation library to understandable-ize the code? :) – None – 2009-11-20T01:14:20.027