codinghorror.com — It's no wonder recruiting good developers is difficult when (quoting the article) "199 out of 200 applicants for every programming job can?t write code at all. I repeat: they can?t write any code whatsoever."
Feb 27, 2007 View in Crawl 4
phillFeb 28, 2007
############################################## FizzBuzz - "Maintainable" Version## 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".## InitStart = 1Stop = 100Fizz = 3Buzz = 5# Loop from Start upto StopStart.upto( Stop ) do |int| # Check for both Fizz and Buzz if ((int % Fizz) == 0) && ((int % Buzz) == 0) puts 'FizzBuzz' next # Skip the rest and loop end # Check for only Fizz if (int % Fizz) == 0 puts 'Fizz' next # Skip the rest and loop end # Check for only Buzz if (int % Buzz) == 0 puts 'Buzz' next # Skip the rest and loop end # Output just the integer puts int end
covertbadgerFeb 28, 2007
@charlesmartin14You seem to have a fairly enormous chip on your shoulder. Go read the article: the point of the challenge is to make sure a candidate is capable of solving a very, very simple problem. It isn't meant to represent real life work, it isn't meant to provide deep insight into your experience or your thought processes, it isn't meant to test your knowledge of arcane syntax or obscure algorithms. It's designed to filter out the type of person who applies for a programming job without knowing how to write a damn for loop. Yes it's a shame that this sort of thing is necessary, but sadly it is. If you walk out of interviews because you think it's beneath you, then the other guys had it right - you're an arrogant assh**e and I wouldn't hire you. Just spend 2 minutes getting past this moron-filter and you can move on to the meat of the interview.
jeff303Mar 1, 2007
GREAT! Now let's see the interpreter
mrkiteMar 2, 2007
"You don't need the extra else sentence. Use % 15while (++$i < 101)if(!($i % 15)) echo "FizzBuzzn";else if(!($i % 3)) echo "Fizzn";else if(!($i % 5)) echo "Buzzn";else echo "$in""Yes, but I wouldn't use yet another variable, because then you'd have 3 to maintain. I'd say if(!($i % (3 * 5)) echo "FizzBuzz"; assuming that those values are defined as constants. ;)
jstandenMar 2, 2007
@dangermouse9The pre-increment and post-increment aren't in the context of before or after "the loop", they're before or after the statement involving 'x'. The third argument of a for loop isn't called until a after an iteration, so the distinction of pre or post doesn't matter.You can see it visually with:for(int x=1;x
krwhiteMar 3, 2007
I'm certainly not digging this article which wishes to slander 'most other people'.. As if a interviewed person is just some static result-set which will never be able to solve that problem, even when he/she's outside a 10 minute trial window in a hot room with an interviewer looking over his/her shoulder. By the way, a good programming scalar is obviously your current state of mind, and I'm sure the average graduate would of been pretty nervous during the job interview. It's not exactly as relaxing as sitting at your own workstation, and is no way a valid test of his/her abilities.Using the scientific method, I'd have to say that these results are inconclusive, and not from enough sources to be sufficient.To give a bit of perspective as to how this 1 in 200 rate could possibly be erroneous.. Think of all of the websites that function smoothly on the Internet everyday, and other various programmatic mechanisms being called into play such as merchant systems. With all the pulling data from databases, and storing information, performing transactions, formatting information, etc.. Everyone reading this is subject to computer algorithms written by programmers, and if it were truly 199 out of 200 that were completely incompetent, then you would probably be seeing mis-charges on your credit card, receiving the wrong items from online stores, data bring presented wrong regularly.More than 1 in 200 programmers get their jobs they set out to get, and certainly more than 1 in 200 perform them well. This obviously proves this absolutely meaningless, and probably even wrong. It's my opinion that more than 1 in 200 can solve this very simple problem, as most people reading this article don't seem to have a problem.It isn't wrong to make a positive leap of faith in 'the other people'. Frankly I'm tired of the ridiculous slander of others online.
stevemaxMar 6, 2007
You missed the line:if (number is not multiple of 3) and (number is not multiple of 5) - say number;
phitheMar 7, 2007
Wow, you're sooo cool. I bet that really happened, too.
kummahiihMar 14, 2007
Sorry. I'm not good at english but anyway:Once I had a job where I was forced to maintain that kind of code and only maintain - I didn't write it at the first place.Some parts of the code were like directly copied from dailywtf.It is so wierd why managers think that bad code can not be rewriten in a quite short time...Then thanks to god I found a better job and a better manager.When I was maintaining "the bad code" jokes like that code wrote to this thread helped me to live with it.IT WAS A JOKE YOU MORAN!
ponosochegMay 12, 2007
Hm... Who's able to open the link?
cogitaMay 24, 2007
Ummm... What an epatage!
poxoeMay 24, 2007
Really good. Seems the server is down.
vikings999Aug 9, 2007
What is this country coming to?<a class="user" href="http://megryan1.bravehost.com">http://megryan1.bravehost.com</a><a class="user" href="http://gearsofwar1.bravehost.com">http://gearsofwar1.bravehost.com</a><a class="user" href="http://savagegardend.bravehost.com">http://savagegardend.bravehost.com</a>
tehtuxpenguinAug 10, 2007
I agree with you. Type 1 does not have passion in programming. But Type 2 does.
jonnylatteDec 22, 2008
char * str[4] = {"%d\n","Fizz\n","Buzz\n","Fizzbuzz\n"}; for(int i = 1; i <101; i++) printf(str[(i%3==0) + (i%5==0) * 2],i); // I have a Job now too