BreakPoint

cancel
Showing results for 
Search instead for 
Did you mean: 

fizbuzz - a simple coding challenge

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

Message 1 of 41
(21,799 Views)

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
Message 2 of 41
(21,787 Views)

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

Message 3 of 41
(21,779 Views)
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 ǝɥʇ'


Message 4 of 41
(21,774 Views)

Henrik,

 

This is not a code obfuscation contest!  😄

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

0 Kudos
Message 5 of 41
(21,768 Views)

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

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 ǝɥʇ'


0 Kudos
Message 6 of 41
(21,761 Views)

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!"


0 Kudos
Message 7 of 41
(21,760 Views)

@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

0 Kudos
Message 8 of 41
(21,757 Views)

@ChrissyC87 wrote:

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


Don't be :(.  You just beat 199 out of 200 people applying for a programming job.  🙂

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

0 Kudos
Message 9 of 41
(21,757 Views)

@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
Message 10 of 41
(21,755 Views)