
Ask HN: What are other 'Fizzbuzz' type interview questions? - jabs83
As a tangent from this article: http:&#x2F;&#x2F;www.gayle.com&#x2F;blog&#x2F;2015&#x2F;5&#x2F;31&#x2F;the-problem-with-the-fizzbuzz-problem<p>What are some other similar type of interview questions that employers might ask to test an applicant&#x27;s coding competency? Regardless of the oppinion of article&#x27;s author I do like the &#x27;fizzbuzz&#x27; problem as one that takes &#x27;just enough coding knowledge&#x2F;thinking&#x27;. Here&#x27;s another example from the article: &#x27;Given a list of people with their birth and end years (all between 1900 and 2000), find the year with the most number of people alive&#x27;<p>Please list other similar type questions. Thanks!
======
soham
There are lots of such questions:

1\. Reverse a String

2\. Find min/max in an array

3\. Find/remove duplicates

4\. IsPalindrome?

5\. Fibonacci (iterative especially)

6\. Primes (IsPrime, print first few etc)

7\. Calculate Factorial

8\. Find one missing number from 1 to N.

9\. Basic Run length encoding (values and their counts)

etc.

It's trivial to come up with such questions, but it's not trivial to deliver
them and judge a person on it. Before asking any of such questions, I'd urge
you to exactly know what you want that person to do and have a sense of where
they are coming from.

(I do this stuff for a living. About me:
[http://InterviewKickstart.com](http://InterviewKickstart.com))

~~~
Someone1234
Plus some of these require background knowledge, for example some candidates
won't know what a Fibonacci number is or how to calculate one (since they
literally haven't covered it for twenty+ years).

So be careful what you're ACTUALLY testing.

~~~
DanBC
The point of FizzBuzz is that you can give candidates a description of the
problem _and also give them the mod operator and a sample of its usage_ and
some people would still fail.

It would be great if there were some actual research on this. (How many people
who claim to be able to program cannot create fizzbuzz in an hour even if you
give them a description of modulo)

I suspect that a lot of it comes from "programming sheep and goats", which was
later withdrawn by its author.

~~~
lsiebert
You don't actually need the modulo operator though.

Modulo is effectively x - x * (x/y) with integers but you don't even need
that.

You can do something like this.

#include <stdio.h> #include <stdbool.h>

int main(void) {

int five = 5; int three = 3; int count; bool numprint;

for (count = 1; count <= 100; count++){ numprint = true; if (count - three ==
0) { three += 3; printf("Fizz"); numprint = false; } if (count - five == 0) {
five += 5; printf("Buzz"); numprint = false; } if (numprint) { printf("%d",
count); } printf("\n"); }

return 0; }

------
jgroszko
One I've had asked of me before is reversing a string, and then I was asked to
re-implement it so that the string is reversed in place. I like this one over
fizzbuzz because it doesn't require the candidate to know about the modulus
operator. It lets you see how the candidate reasons around memory and edge
cases, which come up far more frequently than modulus.

~~~
jotux
A problem with this is that it's asked so frequently people just memorize the
answer.

~~~
trcollinson
This seems to imply that you can't learn about a candidate without giving them
a problem them had not previously memorized. I have most of the solutions to
common problems memorized in a few languages and can complete them on a board
or a txt doc. Does that make me less of a good candidate? Or more?

~~~
jotux
I wouldn't say you can't learn about them but it makes it more difficult. Some
people are really good at memorizing and when you ask them a common problem
it's not useful -- they will just regurgitate the answer and reasoning without
thinking about it. Some people are bad at memorizing and asking them the
problem can be useful, since they have to work through it again, and
fundamentally you want someone who can take a problem and work their way
through it.

Really you should just create simple, unique, problems and ask those problems
to candidates. It's not as easy as just asking the question you were asked,
that you know the answer to, but it will force people to actually show if
they're capable of solving problems and explaining their thought process.

>I have most of the solutions to common problems memorized in a few languages
and can complete them on a board or a txt doc. Does that make me less of a
good candidate? Or more?

I would say this probably makes you good at interviewing but has no impact on
whether I think you would be a good candidate.

------
bartonfink
Two I've seen and enjoyed were:

1.) Given a name, print out the appropriate lyrics to the "name game."

2.) Given a word (and the morse code table), output its Morse code
translation.

~~~
joshuapants
> 1.) Given a name, print out the appropriate lyrics to the "name game."

I like that one!

