Programmers who can’t program
Wednesday, February 28th, 2007Jeff Atwood at Coding Horror asks Why Can’t Programmers Program? and passes along what is considered to be an absolute minimum test for programming competency:
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”.
I’m happy to say I was able to write a working solution in Python in less than four minutes. I’m absolutely shocked that someone would apply for a programming job without being able to do the same in a similar amount of time.
I mean, I’m certainly no professional programmer and I only mess with Python as a hobby… but even I could do write code for FizzBuzz.
Read Jeff’s whole post and check out the other articles he links. Amazing.
Update: For those who asked, here’s my solution:
#!/usr/bin/env python
for number in range(1,101):
if (number % 3) == 0 and (number % 5) == 0:
print "FizzBuzz"
elif (number % 3) == 0:
print "Fizz"
elif (number % 5) == 0:
print "Buzz"
else:
print number



