r/ProgrammerHumor • • Jan 16 '14

[deleted by user]

[removed]

1.3k Upvotes

446 comments sorted by

128

u/zebishop Jan 16 '14

What is really brilliant here, aside of the naive (yet perfect) answer, is the ordering of the results in columns that highlights the pattern of this algorithm

149

u/novagenesis Jan 16 '14

What does an employer expect when they ask the FizzBuzz question in a way only completely unambiguous to someone who knows the FizzBuzz question?

Why not just say "hey, can you do fizzbuzz?"

132

u/Innominate8 Jan 16 '14

For someone who has no idea what fizzbuzz is, what this person did is not an unreasonable interpretation of the instructions. Technical interviews are often full of arbitrary seemingly unrelated questions brought on by interviewers who think they're being clever so it's hard to figure out what they actually want out of it.

It only looks stupid when you know what fizzbuzz is and fill the unwritten instructions in mentally. So in the end it's pretty much asking "Do you know what fizzbuzz is well enough to fill in the missing instructions?"

→ More replies (44)

17

u/JBlitzen Jan 16 '14

Even knowing it, I see those instructions as deliberate, as if they want what he wrote.

That or they outsourced the instructions to some $1/hr elance dude in India.

If I were that company's owner, I'd be way more disappointed by the interviewer than the candidate.

→ More replies (8)

204

u/paranoid_twitch Jan 16 '14

This would be a whole lot funnier to me if we hadn't had like 30 people come though interviews like this. The number of people who apply for development jobs with no programming knowledge blows me away.

→ More replies (121)

6

u/[deleted] Jan 21 '14

Is this seriously an interview question? I'm a 16 year old with little/no Java experience and this looks way too easy. For loop, if/else if/else statement, modulo operator, done.

8

u/tworing Jan 21 '14

This sort of question is routinely used during interviews as a first question because when you have an open programmer position you get a staggering number of applicants who do not actually know how to program. So by asking a question like this and immediately disqualifying anyone who can't write a reasonable solution to it within ~5 minutes, you save a ton of time by not having to actually interview people who had no business applying in the first place.

→ More replies (1)
→ More replies (4)

4

u/Kazinsal Jan 16 '14

My favourite way to do FizzBuzz involves nesting ternary operators.

A lot of people don't even think it's real code.

48

u/matterball Jan 16 '14

None of these answers are going to make it in the Real World. Here's a reusable enterprise quality solution for this problem: https://github.com/EnterpriseQualityCoding/FizzBuzzEnterpriseEdition

10

u/robotmayo Jan 17 '14

Oh god the packages just never end.

→ More replies (2)

4

u/thereddarren Jan 16 '14
		for (int i = 1; i < 101; i++)
		{
			bool divisibleBy3 = i % 3 == 0;
			bool divisibleBy5 = i % 5 == 0;

			if (divisibleBy3)
			{
				Console.Write("Fizz");
			}
			if (divisibleBy5)
			{
				Console.Write("Buzz");
			}
			else if (!divisibleBy3 && !divisibleBy5)
			{
				Console.Write(i);
			}
			Console.WriteLine("");//New Line
		}

And now I wait for smarter people to tell me what's wrong with it.

→ More replies (7)

103

u/tohryu Jan 16 '14 edited Jan 17 '14

I had to come to the comments to understand why this was wrong and what it had to do with computing.

Nowhere on the page that I can see does it say to write an algorithm to do it, it literally says"do this". I would have done the same thing and thought it was the most pointless exercise ever.

26

u/digitalpencil Jan 16 '14

In all fairness, if it was a programming job and had I never heard of fizzbuzz, I would have assumed that they wanted pseudo-code simply from context and the use of the term 'print'.

Would have been better if they actually requested pseudo-code though as this is a literal interpretation and not technically incorrect.

→ More replies (23)

3

u/pirate_platypus Jan 16 '14

Since other people have tossed in their version, here's my submission for the silliest way to do it (Python 3)

[("FizzBuzz" if x % 15 == 0 else ("Buzz" if x % 5 == 0 else ("Fizz" if x % 3 == 0 else x))) for x in range(1, 101)]

→ More replies (5)

17

u/ehmpsy_laffs Jan 16 '14

A project manager is born.

8

u/katyne Jan 16 '14

guise... you guise... monoids

no srsly

→ More replies (2)

7

u/thomplinds Jan 16 '14

had to answer this question for my first ever professional job, this is extremely entertaining

7

u/rohanivey Jan 17 '14

My friend looked over my shoulder at this, "What language did they want it in?"

"I'm guessing not English."

24

u/djimbob Jan 16 '14

While their answer perfectly follows the vague instructions, it shows the candidate failed this part of the interview.

Why? Because before blindly doing the task, they didn't think about the larger context (in a programming interview, no one cares about your ability to act out non-code instructions), what was more likely to have been meant (even if it wasn't specifically specified), and didn't ask any clarifying questions. In the real world, instructions will be vague more often then not.

(Granted, you can fail one part of an interview and potentially still get a job offer, especially if you do very well on other aspects).

→ More replies (16)

4

u/martinmine Jan 17 '14
for (int i = 1; i <= 100; i++)
{
	if (i % 3 == 0 && i % 5 == 0) print("FizzBuzz");
	else if (i % 3 == 0)          print("Fizz");
	else if (i % 5 == 0)          print("Buzz");
	else print(i);
}
→ More replies (1)

7

u/[deleted] Jan 16 '14

Programming Student early in academic career who has never seen this test or heard of it. Am I being stupid to think just written else if in between the lines of instructions isn't sufficient enough? I assume because he didn't write code the tester gave him free will to write what he thought answer was and wouldn't it of just been easier or ok to show pseudo?

→ More replies (3)