O Tannenbaum

December 24, 2013

Merry Christmas to all my readers.

Your task today is to write a program that draws a Christmas tree on the screen; it can be as simple or elaborate as you wish. When you are finished, you are welcome to read or run a suggested solution, or to post your own solution or discuss the exercise in the comments below.

About these ads

Pages: 1 2

4 Responses to “O Tannenbaum”

  1. Santa's Elf said

    In haskell, a nice little christmas tree.

    http://codepad.org/14SQwTia

  2. Santa's Gopher said

    Hacked up version in Go.
    http://play.golang.org/p/uNUoCadnLT

    Merry Christmas!

  3. warrior said

    After looking at other entries I feel I should have tried to spruce it up a bit ;).
    http://codepad.org/oMKIX4Fx

  4. lmon said

    ConPHPigurable Tree:

    $rows = array(1,3,5,7,9,11,13,15,17,20,25,31,2,2,2);
    $cp = $rows;
    sort($cp);
    $wi = $cp[count($cp)-1];

    $char = “*”;
    foreach ($rows as $c) {
    $buff = round(($wi-$c)/2);
    print str_repeat ( ” ” , $buff );
    print str_repeat ( $char , $c );
    print “\n”;
    }

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 599 other followers

%d bloggers like this: