Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Christmas Tree

by spmlingam (Scribe)
on Dec 03, 2008 at 10:29 UTC ( [id://727624]=obfuscated: print w/replies, xml ) Need Help??

This code will print Christmas tree
use strict; my ($y,$z);sub tree{my $x=shift;$x=($x>0?-9: $x);$z=( ($z=($x+5))>0?$z:-$z);printf(!$x&&++$y?"\n":$z? $z>$y %3+$y/ 3?" ":$x<-5?"/":"\\":$y?"|":"*");$y-9?tree( ++$x): print(" _|_|_\n")&&print(" \\___/\n");}tree(1);

Replies are listed 'Best First'.
Re: Christmas Tree
by LanX (Saint) on Jan 06, 2009 at 14:51 UTC
    some perl golfing for xmas-trees! 8 )
    DB<2> printf"%20d%d\n",(4**$_)x2for 1..17 44 1616 6464 256256 10241024 40964096 1638416384 6553665536 262144262144 10485761048576 41943044194304 1677721616777216 6710886467108864 268435456268435456 10737418241073741824 -1-1 -1-1 DB<3> printf'%20d%1$d'.$/,4**$_ for 1..17 44 1616 6464 256256 10241024 40964096 1638416384 6553665536 262144262144 10485761048576 41943044194304 1677721616777216 6710886467108864 268435456268435456 10737418241073741824 -1-1 -1-1 DB<4> ($x=4**$_)=~y/1-9/"/,printf"%22s%s\n",($x)x2for 1..20,0,0 "" """" """" """""" "0"""0"" "0"""0"" """""""""" """""""""" """""""""""" "0""""""0""""" """""0""""""0" """""""""""""""" """0"""""""0"""" """""""""""""""""" "0"""""""""0"""""""" """""""""""""""""""" """""""""""""""""""""" """""""""""""""""""""" """""""0"""""""""""0"""" "0""""""""""""0""""""""""" "" ""

    UPDATE: Maybe someone knows how to further shorten the last, decorated example!

      printf"%22s%s\n",$_%=21,$_=4**$_,y/0/"/cfor 1..22

      Happy New Year! :)

        Thanx, and a happy new year for you too! 8 )

        I have to admit I was confused by your example, it's important to understand that printf takes his parameters by reference and not by value!

        So it's possible to still influence $_ in the last parameter with effect for the first!

        Very insightful, thanx a lot!

        Cheers Rolf

      ♪..♫ Last Christmas I gave you my code ... But the very next day you golfed it away...♩..♬

      DB<99> ($x=4**$_)=~y/1-9/"/,printf"%22s%s\n",($x)x2for 1..20,0,0 "" """" """" """""" "0"""0"" "0"""0"" """""""""" """""""""" """""""""""" "0""""""0""""" """""0""""""0" """""""""""""""" """0"""""""0"""" """""""""""""""""" "0"""""""""0"""""""" """""""""""""""""""" """""""""""""""""""""" """""""""""""""""""""" """""""0"""""""""""0"""" "0""""""""""""0""""""""""" "" ""

      Merry Xmas, Monks and Morlocks! =)

      Cheers Rolf

      ( addicted to the Perl Programming Language)

      Merry Christmas honorable monks! (push! =)

      DB<103> printf"%20d%d\n",(4**$_)x2for 1..17 44 1616 6464 256256 10241024 40964096 1638416384 6553665536 262144262144 10485761048576 41943044194304 1677721616777216 6710886467108864 268435456268435456 10737418241073741824 -1-1 -1-1

      Cheers Rolf

      Merry Christmas honorable monks! (push! =)

      Cheers Rolf

Re: Christmas Tree
by koolgirl (Hermit) on Dec 04, 2008 at 08:08 UTC
    ++! Very cute. ;)
Re: Christmas Tree
by wol (Hermit) on Dec 08, 2008 at 11:11 UTC
    Ooh - pretty!

    But will there be slashes and backslashes all over the bottom of my console come new year?

    --
    .sig : File not found.

Re: Christmas Tree
by hda (Chaplain) on Dec 06, 2008 at 17:33 UTC
    Very nice, indeed!
    I always wonder where do some people get their imagination to make this beautifully strange things.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: obfuscated [id://727624]
Approved by moritz
Front-paged by Arunbear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2024-04-24 22:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found