Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Christmas Tree

by LanX (Chancellor)
on Jan 06, 2009 at 14:51 UTC ( #734447=note: print w/replies, xml ) Need Help??


in reply to Christmas Tree

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!

Replies are listed 'Best First'.
Re^2: Christmas Tree
by mtve (Deacon) on Jan 11, 2009 at 11:56 UTC
    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

        Well, it's a bit complicated, but yes, all perl functions take parameters by reference.
Re^2: Christmas Tree
by LanX (Chancellor) on Dec 17, 2012 at 22:59 UTC
    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

Re^2: Christmas Tree
by LanX (Chancellor) on Dec 23, 2013 at 22:11 UTC
    ♪..♫ 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)

Re^2: Christmas Tree
by LanX (Chancellor) on Dec 22, 2010 at 13:59 UTC
    Merry Christmas honorable monks! (push! =)

    Cheers Rolf

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://734447]
help
Chatterbox?
and the monks are mute...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (12)
As of 2016-12-05 18:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (89 votes). Check out past polls.