Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Golf Challenge: FizzBuzz

by Sidhekin (Priest)
on Mar 02, 2007 at 17:06 UTC ( #602905=note: print w/ replies, xml ) Need Help??


in reply to Golf Challenge: FizzBuzz

My first shot ... how do we count?

perl -le'print(($_%3?"":Fizz).($_%5?"":Buzz)or$_)for 1..100'

Edit: Bah, it's practically merlyn's entry with less whitespacemore golfing. :)

Edit2: With BrowserUK's counting standard, I get 50 if I can assume -l (as he seems to):

sub fizzBuzz { #23456789 123456789 123456789 123456789 123456789 print(($_%3?"":Fizz).($_%5?"":Buzz)or$_)for 1..100 }

... and 5352 if I can't:

sub fizzBuzz { #23456789 123456789 123456789 123456789 123456789 12 print+($_%3?"":Fizz).($_%5?"":Buzz)||$_,$/for 1..100 }

print "Just another Perl ${\(trickster and hacker)},"
The Sidhekin proves Sidhe did it!


Comment on Re: Golf Challenge: FizzBuzz
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://602905]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (11)
As of 2015-07-29 08:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (261 votes), past polls