10

I recently found out that Facebook had a programming challenge that if completed correctly you automatically get a phone interview.

There is a sample challenge that asks you to write an algorithm that can solve a Tower of Hanoi type problem. Given a number of pegs and discs, an initial and final configuration; Your algorithm must determine the fewest steps possible to get to the final configuration and output the steps.

This sample challenge gives you a 45 minute time limit but allows you to still test your code to see if it passes once your time limit expires.

I did not know of any cute math solution that could solve it, and I didn't want to look for one since I think that would be cheating. So I tried to solve the challenge the best I could on my own.

I was able to make an algorithm that worked and passed. However, it took me over 4 hours to make, much longer than the 45 minute requirement. Since it took me so much longer than the allotted time, I have not attempted the actual challenge.

This got me wondering though, in reality does it really matter that it took me that long? I mean is this a sign that I will not be able to get a job at a place like this (not just Facebook, but Google, Fog Creek, etc.) and need to lower my aspirations, or does the fact that I actually passed on my first attempt even though it took too long be taken as good?

JD Isaacks
  • 8,926

7 Answers7

42

In practice it does matter how long it takes you. One that can solve the problem in 45 minutes is - all else equal - five times more productive than one that takes 4 hours, and hence more attractive to an employer.

That said, you do not say why you took four hours to solve this problem.

  • Were you at your best (well-fed, not tired, fully concentrated)?
  • Was the problem well specified, or did you need to do additional research on your own?
  • Did you have to learn new things to do this?
  • Were the tools familiar or not?
  • etc.

Any and all of these things might influence the time it takes you, and it is actually more important to be able to solve a problem when under pressure, without being told everything, and with the tools at hand, since that WILL happen during your career and it is usually at a point where it is very important to somebody whether you succeed or not.

13

It does matter, to a company that is looking for general developers with good cash flow, because faster means more work can get done. However, in many other cases (I would argue in most cases, actually), it doesn't matter as much as your ability to solve problems, and your ability to solve them well.

I can think of five different types of problem solvers:

Those who...

  1. ...can solve problems quickly, with a clean and efficient solution.
  2. ...can solve problems quickly, but with a dirty and inefficient solution.
  3. ...can solve problems slowly, but end up with a clean and efficient solution.
  4. ...can solve problems slowly, but end up with a dirty and inefficient solution.
  5. ...cannot solve problems, either quickly, or slowly.

A Facebook-style test explicitly weeds out #3, #4, and #5 candidates because it has a time constraint, so we know that this test is for employers who have determined that they should only hire #1 or possibly #2 candidates (depending on further screening).

Some examples:

  • An employer like Facebook might only be looking for #1 programmers only, since they can afford huge salaries for super-star programmers.
  • An employer that has a high-volume of one-off sales (like some web design shops) might only want a #2 developer, who are cheaper than the equally effective #1 developers.
  • An employer that has a specialized problem domain (such as writing loan origination software), might accept a #3 developer over a #1 developer, since a dual-degree genius developer might be super-expensive, or they might be hard to find.
  • An employer that doesn't care or has limited budget for various reasons might be OK with a #4 developer.
  • #5 developers get hired by firms that don't know what they're looking for and fail to screen those applicants out.
5

Tower of Hanoi? That was one of the first programming assignments I had on my freshman course at university (right after Fibonacci - yes, I had classes with one of those functional programming freaks :). And I'm not even on computer science, I'm on computer engineering.

And still, most so-called 'programmers' can't write this kind of algorithm correctly, because most programmers are awful. (search for fizzbuzz for added fun)

Anyway, once you are past a certain threshold, I think your programming skills doesn't matter as much as your ability to finish projects, your resiliency against difficulties, etc. And it seems you are past it for sure.

Facebook wants to hire the top devs, sure, but I don't know how much of them they hope to get with those kinds of games. I think they just don't want to lose time with awfully bad programmers.

A tip I always hear is that if you want to get hired by a cool tech company, try to get involved with open source projects. Also, try to get a internship.

elias
  • 109
3

When there is a lot of supply (many would-be programmers) and a little demand (few programming jobs) employers can be as demanding as they wish to be. As a matter of fact, they have to be demanding, or else they would be spending inordinate amounts of time interviewing people instead of getting any work done. So, they are giving candidates extremely hard tests so as to get a short list as quickly as possible, and so as to ensure that they will be interviewing people who are not just good, not even very good, but actually charismatic.

So, the fact that you did not complete the test within the allotted time frame does not mean you are a bad programmer; you just do not happen to fit the definition of what facebook considers charismatic. In my opinion, that's okay.

Mike Nakis
  • 32,803
0

Time maters but don't get the idea that you're stupid if it takes you longer. A lot of people have things "memorized". They practice applying techniques like recursion so much that it becomes 2cd nature. It's not that their smarter, they just have practiced to the point of 2cd nature and you can too!

Consider the following math problem: 2+2=?

If you immediately knew the answer was 4 it's not because you're smart, but because it's 2cd nature. A child learning to add may be forced to go through the most basic operations of counting to get the answer. But that child may have the potential to surpass the adult.

Lord Tydus
  • 1,441
-1

People don't really care how much time you spend doing something; just meet your deadlines and all's well.

user541686
  • 8,178
-1

It's quite tense, It would require me to read about what is tower of Hanoi -15min, start the IDE, create a blank solution -5min, so that's only 25 minutes to solve the problem. Simply writing code with all the plumbing like safe classes with good interface design would require some time as well -10min, so it's 15 minutes left for the actual idea. Depending on what is the tower on Hanoi, it might be enough, bit it might be not. And sometimes, I just need to let the problem solve itself while I'm working on other problems, because I don't see the solution right there on the spot. So it gets solved for free in a parallel thread, but it doesn't happen in an instant.

Anyway, it's one of the largest companies, so they can do whatever they want. But time limit is one of the worst factors in interviews IMHO, I always feel pressed, rushed, can't do everything clean, and can't concentrate on all details which are very important when actually working. :) Sure you can solve solutions fast, like, set access to admin so that everything works + 'SELECT * FROM pass WHERE usr == ' + user_input, but for any secure and well written task I would be proud with, I would need some time and 45 minutes is really quite intense.

Coder
  • 6,978