Your skill will accomplishwhat the force of many cannot PerlMonks

### Christmas Tree

by spmlingam (Scribe)
 on Dec 03, 2008 at 10:29 UTC 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 (Chancellor) 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

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

♪..♫ 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! =)

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?

--

Re: Christmas Tree
by hda (Hermit) 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.

Create A New User
Node Status?
node history
Node Type: obfuscated [id://727624]
Approved by moritz
Front-paged by Arunbear
help
Chatterbox?
 [Corion]: A good daypart to everybody!

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (6)
As of 2017-06-29 07:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
How many monitors do you use while coding?

Results (655 votes). Check out past polls.