On occasion you meet a developer who seems like a solid programmer. They know their theory, they know their language. They can have a reasonable conversation about programming. But once it comes down to actually producing code they just don’t seem to be able to do it well.
You would probably think they’re a good developer if you’ld never seen them code. This is why you have to ask people to write code for you if you really want to see how good they are. It doesn’t matter if their CV looks great or they talk a great talk. If they can’t write code well you probably don’t want them on your team.
After a fair bit of trial and error I’ve come to discover that people who struggle to code don’t just struggle on big problems, or even smallish problems (i.e. write a implementation of a linked list). They struggle with tiny problems.
So I set out to develop questions that can identify this kind of developer and came up with a class of questions I call “FizzBuzz Questions” named after a game children often play (or are made to play) in schools in the UK.
In this game a group of children sit around in a group and say each number in sequence, except if the number is a multiple of three (in which case they say “Fizz”) or five (when they say “Buzz”). If a number is a multiple of both three and five they have to say “Fizz-Buzz”.
An example of a Fizz-Buzz question is the following:
[quote]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”.[/quote]
Most good programmers should be able to write out on paper a program which does this in a under a couple of minutes.
Want to know something scary ? – the majority of comp sci graduates can’t. I’ve also seen self-proclaimed senior programmers take more than 10-15 minutes to write a solution.
I’m not saying these people can’t write good code, but to do so they’ll take a lot longer to ship it. And in a business environment that’s exactly what you don’t want.
This sort of question won’t identify great programmers, but it will identify the weak ones. And that’s definitely a step in the right direction.
What, is this “post the same boring shit we've all seen Buzz times” day?
Name:
Anonymous2009-12-04 0:52
On occasion you meet a developer who seems like a solid programmer. They know their theory, they know their language. They can have a reasonable conversation about programming. But once it comes down to actually producing code they just don’t seem to be able to do it well.
You would probably think they’re a good developer if you’ld never seen them code. This is why you have to ask people to write code for you if you really want to see how good they are. It doesn’t matter if their CV looks great or they talk a great talk. If they can’t write code well you probably don’t want them on your team.
After a fair bit of trial and error I’ve come to discover that people who struggle to code don’t just struggle on big problems, or even smallish problems (i.e. write a implementation of a linked list). They struggle with tiny problems.
So I set out to develop questions that can identify this kind of developer and came up with a class of questions I call “FizzBuzz Questions” named after a game children often play (or are made to play) in schools in the UK.
In this game a group of children sit around in a group and say each number in sequence, except if the number is a multiple of three (in which case they say “Fizz”) or five (when they say “Buzz”). If a number is a multiple of both three and five they have to say “Fizz-Buzz”.
An example of a Fizz-Buzz question is the following:
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”.
Most good programmers should be able to write out on paper a program which does this in a under a couple of minutes.
Want to know something scary ? – the majority of comp sci graduates can’t. I’ve also seen self-proclaimed senior programmers take more than 10-15 minutes to write a solution.
I’m not saying these people can’t write good code, but to do so they’ll take a lot longer to ship it. And in a business environment that’s exactly what you don’t want.
This sort of question won’t identify great programmers, but it will identify the weak ones. And that’s definitely a step in the right direction.
int i;
for(i = 1; i <= 100; ++i){
int x;
x = i;
while(x > 0){
x /= 5;
}
if(x == 0){
x = i;
while(x > 0){
x /= 3;
}
if(x == 0){
printf("Fizz");
}
printf("Buzz");
}
else{
x = i;
while(x > 0){
x /= 3;
}
if(x == 0){
printf("Fizz");
}
else{
printf("%d", i);
}
}
}
Name:
Anonymous2009-12-04 6:17
ENTERPRISE UNIX SOLUTIONS
for i in $(gseq 100); do
s=""
(gfactor $i | grep -q ' 3') && s="Fizz"
(gfactor $i | grep -q ' 5') && s="${s}Buzz"
[ -z "$s" ] && s="$i"
echo $s
done
Name:
Anonymous2009-12-04 6:23
print(*list(map(lambda n: n % 15 and (n % 5 and (n % 3 and n or "Fizz") or "Buzz") or "FizzBuzz", range(1, 100))))
Works just fine, but definetly needs some FORCED INDENTATION OF CODE
Didn't we have this thread a few times already?
Here's my versions:
(defun is-divisible (x n)
(zerop (mod x n)))
(loop
for i from 1 to 100 do
(let ((mod3 (is-divisible i 3))
(mod5 (is-divisible i 5)))
(cond
((and mod3 mod5) (format t "~&FizzBuzz~&"))
(mod3 (format t "~&Fizz~&"))
(mod5 (format t "~&Buzz~&"))
(t (format t "~&~A~&" i)))))
(loop
for i from 1 to 100 do
(let ((result))
(format t "~&~{~A~}~&"
(progn
(when (is-divisible i 5) (push "Buzz" result))
(when (is-divisible i 3) (push "Fizz" result))
(unless result (push i result))
result))))
Crap, I forgot my code tags.
(defun is-divisible (x n)
(zerop (mod x n)))
(loop
for i from 1 to 100 do
(let ((mod3 (is-divisible i 3))
(mod5 (is-divisible i 5)))
(cond
((and mod3 mod5) (format t "~&FizzBuzz~&"))
(mod3 (format t "~&Fizz~&"))
(mod5 (format t "~&Buzz~&"))
(t (format t "~&~A~&" i)))))
(loop
for i from 1 to 100 do
(let ((result))
(format t "~&~{~A~}~&"
(progn
(when (is-divisible i 5) (push "Buzz" result))
(when (is-divisible i 3) (push "Fizz" result))
(unless result (push i result))
result))))
int main(void)
{
int i;
int dicks = 0;
for (i = 1; i < 101; ++i)
{
if (i%3 == 0) printf("Fizz");
if (i%5 == 0) printf("Buzz");
if (!(i%3 == 0 || i%5 == 0)) printf("%d", i);
printf("\n");
}
return dicks;
}
Name:
Anonymous2009-12-04 19:32
>>26
Does java allow the two alternatives of a conditional expression to be of non-convertible types?
Name:
Anonymous2009-12-04 20:56
I'll be honest with you, /prog/.
//Start - 8:38 PM
//End - 8:44 PM
//Real End - 8:50 PM (it took me 6 minutes to realize that I wrote (x % 3 = 0) instead of (x % 3 == 0), I'm a retard
#include <stdio.h>
fizzbuzz (int max)
{
int x;
for (x = 1; x <= max; x++)
{
if (x % 3 == 0)
printf ("Fizz");
if (x % 5 == 0)
printf ("Buzz");
if (x % 3 != 0 && x % 5 != 0)
printf ("%d", x);
printf ("\n");
}
}
main ()
{
int x;
printf("Input a number to Fizzbuzz: ");
scanf("%i", &x);
fizzbuzz (x);
}
int main() {
int fizz = 0, buzz = 0;
int i;
for (i = 1; i <= 100; ++i) {
if (fizz == 0) printf("Fizz"), fizz = 3;
if (buzz == 0) printf("Buzz"), buzz = 5;
if (fizz != 3 || buzz != 5) printf("%d",i);
--fizz, --buzz,
printf("\n");
}
}
// prints extra return at the beginning
int main() {
unsigned int i;
for (i = 4; i <= 402; i += 2) {
if (i & 2) printf("%d", i >> 2);
else {
printf("\n");
if (i % 12 == 0) printf("Fizz"), ++i;
if (i % 20 == 0) printf("Buzz"), ++i;
i &= ~1;
}
}
}
for i in range(1,101):
temp=''
if not i%3:
temp+="Fizz"
if not i%5:
temp+="Buzz"
if temp:
print temp
else:
print i
Name:
Anonymous2009-12-06 23:05
for i in xrange(1,101):
if (i % 3) and (i % 5):
print i
else:
if not(i % 3 or i % 5):
print "fizzbuzz"
if not(i % 3):
print "fizz"
if not(i % 5):
print "buzz"
Name:
Anonymous2009-12-06 23:24
module Main where
import IO
fizz 101 = []
fizz n = if ((mod n 3) == 0) && ((mod n 5) ==0) then ["Fizzbuzz"] ++ fizz (n + 1)
else if ((mod n 3) == 0) then ["Fizz"] ++ fizz (n + 1)
else if ((mod n 5) == 0) then ["Buzz"] ++ fizz (n + 1)
else [(show n)] ++ fizz (n + 1)
main = mapM_ putStrLn (fizz 1)
I'm new to Haskell, any suggestions?
Name:
Anonymous2009-12-06 23:39
More like JizzBuzz
package org.fourchan.dis.read.prog.p125905156;
public class Buzza extends Object
{ public static void main (String [] args)
{ StringBuilder stringBuilder = new StringBuilder();
for (long i = 1; i <= 100; i++)
{ boolean isMultipleOf3 = i % 3 == 0 ? true : false;
boolean isMultipleOf5 = i % 5 == 0 ? true : false;
if (isMultipleOf3)
stringBuilder.append("Fizz");
if (isMultipleOf5)
stringBuilder.append("Buzz");
if (!isMultipleOf3 && !isMultipleOf5)
stringBuilder.append(i);
}
System.out.print(stringBuilder.toString());
}
}
Name:
Anonymous2009-12-07 1:13
>>43
U MENA: fizz n
| three && five = "FizzBuzz\n"
| three = "Fizz\n"
| five = "Buzz\n"
| otherwise = ""
where three = mod n 3 == 0
five = mod n 5 == 0
main = mapM_ (putStrLn . fizz) [1..100]
I wasn't really trying very hard.
>>48-49
You seem to forget your code tags every time you post some code. Why don't you finally write yourself a note about these bloody tags and stick it to your display?
for i,j,k in zip(map(lambda x: x % 3 == 0, range(1,101)), \
map(lambda x: x % 5 == 0, range(1,101)), range(1,101)):
dicks = "fizzbuzz" if i == True and j == True else \
"fizz" if i == True else \
"buzz" if j == True else \
k
print dicks
>>75
Why do php programmers love doing everything in wrong and broken ways? I keep seeing php code that overcomplicates the problem, fails to solve the problem at all and best of all, looks nothing at all like code that is even remotely interested in the problem.
>>81
The majority of PHP code I've seen contains something a lot like >>75. Even if it is a troll, someone somewhere has written PHP like that and meant it, and everyone in this thread has seen it (even if only by accident, say when apache fails to load mod_php: the result is php of this caliber.)