cancel
Showing results for 
Search instead for 
Did you mean: 

fizbuzz - a simple coding challenge

jcarmody
Trusted Enthusiast

fizbuzz - a simple coding challenge

Message contains a hyperlink

I read today's Coding Horror blog titled "How to Hire a Programmer", then followed a link to another titled "Why Can't Programmers... Program?"  It was in the second one that I read "[...] 199 out of 200 applicants for every programming job can't write code at all. I repeat: they can't write any code whatsoever."  The author meant that quite literally.  He then suggested a simple coding test to weed out the non-programmers:

Write a program that prints the numbers from 1 to 100. But for multiples of three print "Fizz" instead of the number and for the multiples of five print "Buzz". For numbers which are multiples of both three and five print "FizzBuzz".

The comment that got me to write a solution was "Most good programmers should be able to write out on paper a program which does this in a under a couple of minutes."  Could I write this in just a minute or two (or three)?  I wasn't too surprised that I could, and I expect that many of y'all can, too.

 

This would be a good test for folks that are just beginning (students, I'm talking to you).  Perhaps you've passed the CLAD (or CLD) and are feeling pretty good about yourself.  Try it, you may like it.

 

 

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

40 REPLIES 40
EvenDeejay
Active Participant

Re: fizbuzz - a simple coding challenge

Message contains an image

A nice task I hope I solved without any Rube Goldberg codeSmiley Happy

 

FizzBuzz.png 

Regards,
Even
_________________________________
Certified LabVIEW Associate Developer

Automated Test Developer
Topro AS
Norway
jcarmody
Trusted Enthusiast

Re: fizbuzz - a simple coding challenge

Message contains an image

Mine was similar:

  

Spoiler
fizbuzz.png

 

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

Henrik_Volkers
Trusted Enthusiast

Re: fizbuzz - a simple coding challenge

Message contains an image
Spoiler
FizzBuzz.png
Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


Highlighted
jcarmody
Trusted Enthusiast

Re: fizbuzz - a simple coding challenge

Henrik,

 

This is not a code obfuscation contest!  Smiley Very Happy

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

Henrik_Volkers
Trusted Enthusiast

Re: fizbuzz - a simple coding challenge

I haven't tested it for speed, however I wanted to avoid two quotient&remainder vis  Smiley Very Happy

How about a one line regular expression someone?

 

Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


ChrissyC
Active Participant

Re: fizbuzz - a simple coding challenge

Message contains an image

Mine's v.similar to jcarmody's, but slightly more convoluted thanks to the select VIs Smiley Sad

 

Spoiler
Fizzbuzz.JPG

 

 

----------------------------------------------------------------------------------------------------------------------------
"If anyone needs me, I'll be in the Angry Dome!"


jcarmody
Trusted Enthusiast

Re: fizbuzz - a simple coding challenge


@Henrik Volkers wrote:

I haven't tested it for speed, however I wanted to avoid two quotient&remainder vis 


I was referring to your first solution.


@Henrik Volkers wrote:

 

How about a one line regular expression someone? 


Hmmm...

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

jcarmody
Trusted Enthusiast

Re: fizbuzz - a simple coding challenge


@ChrissyC87 wrote:

Mine's v.similar to jcarmody's, but slightly more convoluted thanks to the select VIs Smiley Sad


Don't be Smiley Sad.  You just beat 199 out of 200 people applying for a programming job.  Smiley Happy

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

P@Anand
Trusted Enthusiast

Re: fizbuzz - a simple coding challenge

Message contains an image

@Even Deejay wrote:

A nice task I hope I solved without any Rube Goldberg codeSmiley Happy

 

FizzBuzz.png 


Still small thing you have that kind. You could have used Equal2Zero.png instead of Equal2Zero - 1.png. Smiley Wink

-----

The best solution is the one you find it by yourself