Smallest FizzBuzz program

R

Robert Dober

1.upto(?d){|i|p ["%sBuzz"%x=[:Fizz][i%3]][i%5]||x||i}

Code golfing is against my religious beliefs however.
good decision ;) 'cause you are cheating, the output format of p is
not what is required :(
Robert

And here I could have sworn that I'd actually tried that very code in irb.

That's why I'm against code golfing, rots the brain! ;-)
That's why I love it, nothing to lose ;)
But this one got on my nervers now, good night everyone!
 
B

Brian Adkins

Brian said:
This is really bugging me. Someone posted a golf challenge to write a
smallest FizzBuzz program here:

http://golf.shinh.org/p.rb?FizzBuzz (although the site was down when I
checked it a few minutes ago)

I submitted the resulting program to the site (which is back up now)
under 'comp.lang.ruby' since multiple people contributed. Comes in at 57
bytes - only 1 byte longer than the best. So apparently the site does
count the EOF byte.

1.upto(?d){|i|i%3<1&&x=:Fizz;puts i%5<1?"#{x}Buzz":x||i}

http://golf.shinh.org/p.rb?FizzBuzz

Interestingly, the following Ruby program (with a little help from sed
that my friend passed along) comes in at exactly 56 bytes, but the test
site rightfully failed it due to the attempt to shell the command:

puts `seq 100|sed -e'5~5s/.*/Buzz/;3~3s/^[0-9]*/Fizz/'`
 
R

Robert Dober

I was trying to submit to program for the prime number challenge, but I
can't make it work because I don't understand how does this website do the
input to the submitted programs.
I mean that when I use ARGV or $*, it seems these variables are empty (just
submitting a test program that does a "pp ARGV" outputs an empty array).

Is there anyone who knows how can I get the input for this website ?
Did you try to read from $stdin? I know that is kind of stupid to ask,
but sometimes we do not see what is hidden in front of our eyes :)

Robert
 
J

Jenda Krynicky

Brian said:
This is really bugging me. Someone posted a golf challenge to write a
smallest FizzBuzz program here:
...

Hey! Stop this! It's supposed to be the dreadfull scripting language
called Pearl that's totally unreadable and it's abusers waste the
precious time trying to beat each other by writing something in as few
characters as possible!

:p

Jenda
 
M

Martin DeMello

Hey! Stop this! It's supposed to be the dreadfull scripting language
called Pearl that's totally unreadable and it's abusers waste the
precious time trying to beat each other by writing something in as few
characters as possible!

The email address simply drips irony :)

m.
 
R

Rick DeNatale

The email address simply drips irony :)

And what's pearl? I thought it was perl. What does it mean if one
doesn't know how to properly spell one's favorite language?

You could always tell who was really in the Smalltalk community or at
least who wasn't when they spelled it SmallTalk.
 
R

Robert Dober

And what's pearl? I thought it was perl. What does it mean if one
doesn't know how to properly spell one's favorite language?

You could always tell who was really in the Smalltalk community or at
least who wasn't when they spelled it SmallTalk.
Oh Rick just forget him, he will become a stone in the sun.

R
 
R

Robert Dober

Why does conjure up a picture of Mick Jagger lying on a beach?
I guess I lack some cultural reference to understand this :)
I was just talking about Trolls as in Tollkien et al..

R.
 
R

Rick DeNatale

I guess I lack some cultural reference to understand this :)
I was just talking about Trolls as in Tollkien et al..

Mick Jagger is the lead singer of the Rolling Stones.

Robert my friend you must be either very old or very young (more likely)
 
C

Chad Perrin

And what's pearl? I thought it was perl. What does it mean if one
doesn't know how to properly spell one's favorite language?

Actually, in this context, I think "Jenda" is being intentionally
ironic. That's a jab at people who complain about Perl being unreadable
and suitable only for golf and obfu.
 
R

Robert Dober

Mick Jagger is the lead singer of the Rolling Stones.

Robert my friend you must be either very old or very young (more likely)

Actually I am quite old (not as old as the Stones but almost), but
incredibly stupid, I just did not get the pun!!!!Thx for bringing the light to the blind.

Robert
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,158
Latest member
Vinay_Kumar Nevatia
Top