FizzBuzz Alternative Questions

Anyone have any good questions like FizzBuzz that aren't FizzBuzz issue?

I am talking with someone, and FB is relatively well known and not so difficult to remember, so my first stop in the search for ideas is my new SO dependency.

+74
fizzbuzz
Sep 22 '08 at 21:39
source share
14 answers

I saw a short list of relatively simple programming problems used to clip candidates like FizzBuzz. Here are some of the problems that I have seen, in increasing order of difficulty:

  • Return line
  • Reverse sentence (“Bob loves dogs” → “dogs love bean”)
  • Find the minimum value in the list
  • Find the maximum value in the list
  • Calculate the remainder (taking into account the numerator and denominator)
  • Returns individual values ​​from a list, including duplicates (i.e. "1 3 5 3 7 3 1 1 5" → "1 3 5 7")
  • Returns individual values ​​and their number (i.e. the list above becomes "1 (3) 3 (3) 5 (2) 7 (1)")
  • Given a string of expressions (only variables, + and -) and a set of pairs of variables / values ​​(i.e. a = 1, b = 7, c = 3, d = 14) returns the result of the expression ("a + b + c - d "will be -3).

It was for Java, and you could use standard libraries, so some of them can be extremely lightweight (e.g. 6). But they work like FizzBuzz. If you have a key to programming, you should do it pretty quickly. Even if you don’t know the language well, you should at least make it clear how to do something.

Using this test, one of my previous bosses saw everything from people who got it all pretty fast, to people who could do it very quickly, to one guy who couldn't answer a single half an hour later.

I should also note: he allowed people to use their computer while they were given these tasks. They were specifically advised that they could use Google, etc.

+85
Sep 22 '08 at 21:54
source share

This may not answer your question directly, but I'm not sure if you need to come up with another problem. Besides being “easy to remember,” the FizzBuzz question is simply “simple,” and that's the point. If the person you are interviewing is in the class of people that FizzBuzz is “well known for,” then they are in the class of people and a question like FizzBuzz will not be filtered out. This does not mean that you hire them locally, but it does mean that they should be able to get through it and enjoy the interview.

In other words, someone who spends time reading Coding Horror should interview further. They just need to quickly write out a solution, briefly discuss it (for example, how do you test this?), And then move on to the next question. And, as the article says, "it is truly amazing how many candidates are incapable of the simplest programming tasks."

+25
Sep 23 '08 at 2:39
source share

Any of the earlier ones from Project Euler are likely to be good.

For example:

Problem 25

The Fibonacci sequence is determined by the recurrence relation:

Fn = Fn−1 + Fn−2, where F1 = 1 and F2 = 1. 

Therefore, the first 12 members will be:

 F1 = 1 F2 = 1 F3 = 2 F4 = 3 F5 = 5 F6 = 8 F7 = 13 F8 = 21 F9 = 34 F10 = 55 F11 = 89 F12 = 144 

The 12th member of F12 is the first term containing three digits.

What is the index of the first term in a Fibonacci sequence containing 1000 digits?

+20
Sep 22 '08 at 22:12
source share

I found that checking the string, if it is a palindrome, is quite simple, which can be a decent weed.

+11
Sep 22 '08 at 21:47
source share

Fibonacci, the reverse line, the number of samples of bits in a byte are other common. Project Euler also has a large collection of growing challenges.

+7
Sep 22 '08 at 21:42
source share

I need a FizzBuzz question that is not related to the modulo operator. Moreover, I usually interview web developers for whom the modulo operator just doesn’t arise so often. And if this is not what you encounter regularly, this is one of those things that you look at several times when you need it.

(Of course, this is a concept that, ideally, should have been found in a mathematical course somewhere along the way, but this is a different topic.)

So, I came up with what I call, unimaginably, Threes in Reverse . Instruction:

Write a program that issues in the reverse order, each multiple of 3 from 1 to 200.

Doing this in the usual way is easy: multiply the loop index by 3 until you reach a number greater than 200, and then close. You do not need to worry about how many iterations will stop after, you just keep going until you reach too high a value.

But going back, you need to know where to start. Some may intuitively understand that 198 (3 * 66) is the highest multiple of 3, and as such, hard code 66 per loop. Others may use a mathematical operation (integer division or gender () for 200 and 3 floating point division) to figure out this number and still provide something more general applicable.

In fact, this is the same problem as FizzBuzz (switching values ​​and printing them using a twist). This is one of the problems for the solution, which does not use anything as (relatively) esoteric as the modulo operation.

+6
Oct 25 2018-10-10 at
source share

For something really super-simple, which can be done in 10 seconds, but will delete those people who literally can’t program anything, try the following:

Ask: show me (on paper, but better on the board) how you would change the values ​​of two variables.

This was not my idea, but was posted in a comment by someone named Jacob on a blog post all about the original FizzBuzz question.

Jacob goes on to say:

If they do not start by creating a third variable, you can pretty much write that the person is off. Ive discovered that I can cut off from the third to half of my (admittedly, unscreened at this moment) applicants with only this issue.

After this comment on the original blog post on how to execute this variable, an additional interesting discussion is required that does not require a third variable (add / subtract, xor, etc.) and, of course, if you use a language that supports this in one operator / operation, this may not be such a good test.

Although this is not my idea, I wanted to publish it here, because it is such an elegantly simple and simple question that can (and should) be answered within about 10 seconds by those who wrote even the simplest of programs. It also does not require the use of a few explicitly hidden operators, such as the modulo operator, which many people who are otherwise pretty decent programmers simply are not familiar with (which I know from my own experience).

+5
Oct 30 '10 at 9:41
source share

Ask them to write an application to return factors of a given number. It is easy to do and hard to succeed in a short period of time. You can see their style and how they think through problems for a short period of time.

+3
Sep 22 '08 at 21:42
source share

Returns the index of the first occurrence of row X in row Y

The strstr () implementation requires a basic understanding of the language, providing the opportunity for smart optimization.

+2
Sep 22 '08 at 21:55
source share

If this is an interview in C / C ++, make sure that the person knows about pointers.

General - a simple algorithm ([single / double] linked list). Ask about the difficulty of adding in each case (at the beginning, at the end, optimization ...)?

(General) How do you find min and max from an array (size N) with just 3 * N / 2 comparisons?

C / C ++: How would you optimize multiple strcat in the buffer?

+2
Sep 22 '08 at 22:02
source share

How about: I want to use a single integer to store multiple values. Describe how this will work.

Unless they have a clue about bit masks and operations, they probably won't be able to solve other problems.

+1
Sep 22 '08 at 21:45
source share
+1
Sep 22 '08 at 21:48
source share

Finding a list of primes is a fairly common question, but it still requires some thought, and there are varying degrees of answers that people can give.

You will also be surprised how many people are trying to implement a Map / Dictionary data structure.

0
Sep 22 '08 at 21:47
source share

I asked my candidates to create a program to calculate the factorial of a given number in any pseudo-language of my choice. This is a fairly simple problem to solve, and it fits well with the natural requirements (which can often be asked) about recursion.

0
Jun 09 '10 at
source share



All Articles