I've never understood the use of puzzles and tests for hiring. I'm notoriously bad at them, but I consider myself to be a very solid programmer, with 13 years professional web development experience, and a major open source project under my belt.
I think one of the reasons I don't do well on these is because my brain doesn't seem to work well for hypotheticals. I need real world use cases or else it's exceedingly difficult for me to work out a solution for a problem that is too abstract.
Maybe I'm unique amongst other programmers with my level of experience. It's possible that other programmers love doing puzzles like this, but I tend to get discouraged if I'm looking at a company, and they use tests and puzzles to gauge my capabilities.
Especially (and I wouldn't accuse Facebook of this, but it happens much too often), if those tests and puzzles are substitutes for looking at the massive amounts of code I've written.
The Facebook puzzles are pretty easy. That being said, I hate puzzles too. I think it's pretty degrading to ask a well-established researcher/engineer to do that kind of stuff. On interviews I typically ask people to give a talk about their previous projects in detail. A lot of nuances arise during these talks that allow you to quite easily judge the level of the candidate.
I think the attitude of a lot of companies, especially the ones hiring fresh grads, is that the ability to think is more important than the ability to code (the latter of which can be taught far more easily than the former).
I don't mean to imply that you are unable to think, of course - the puzzles are surely an imperfect heuristic - but that's my understanding of their aim.
How are these puzzles hypothetical? They look better written in specification than specs in the real world:
(selected few and summarized...)
Hoppity Hop!
Input: filename as arg from command prompt, file contains a number
Output: Some variation on the word "Hoppity" repeated
Simon Says
the gist: Connect to some server, call some api's in a certain order.
Battleship - write a client that connects to some server that plays battleship...
Find Sophie - read some data,build some data structures/run algorithm,output result
Input: filename and specifications of the file format
Output: result
Some test simple programming skills (Hoppity Hop is basically the Fogbugz for-loop question + no brainer file parsing) and the harder ones seem to involve knowledge of (not too tough) algorithms.
If the questions were more like "How would you move Mt. Fuji", then that's certainly hypothetical.
Please don't ask me to review your "massive amounts of code" - I guarantee you will not come out ahead in that evaluation, if I even have time to properly evaluate it (according to Code Complete, you can properly review code in a high-level language at about 100-500 lines per hour).
If you consider the fact that:
- It is unlikely I am well-versed in the problem domain of your code,
- I am unlikely to be aware of external design constraints or coding pressures,
- I am probably going to randomly select the worst section of code to review,
- I have no context for how the code evolved
the chances that I walk away with a negative impression are high enough that it should give you pause. If I do manage to walk away with a positive impression of your code, it will be offset by the perception that you believe your time is more valuable than mine (why else would you send me a massive amount of code and ask me to review it to determine your suitability for a position) - and you still haven't answered the other big question I need answered which is whether you are a good "fit" for the team from a personality/cultural perspective.
If you really want to impress me, go ahead and send me a list of your projects and contributions and then slice a relevant sample of code from it. Describe what the problem was and how you solved it so I can understand the context. Try to make it relevant to the position, but failing that describe how you could utilize that experience in the relevant domain. Keep it small enough that I can review it in under an hour or two.
Is it a lot more work for you? Absolutely, but if you do this I guarantee you I will look at your code and will likely call you for an interview because you are demonstrating a high level of competence and professionalism while still respecting my time and needs.
The reality, for better or for worse, is that a lot of the companies that are using puzzles like this prefer false negatives over false positives. In other words, they would rather pass over the occasional excellent engineer than accidentally hire a mediocre engineer. This is the case at Google, Amazon et al, and likely at Facebook and others as well. It very well might be the case that you're just an unfortunate casualty of this sort of hiring practice.
Most of the time anyone with solid engineering background, industry experience, programming contest medals, or entrepreneurial streak would have no problem landing an interview.
However, that leaves a whole lot of candidates out of the picture. Faced with limited recruiting resources, puzzles are about the next best thing to serve as a recruiting filter. Plus some people send them in without being told to, which is usually a plus, as it implicates coding in their spare time is something they enjoy doing.
These FB puzzles test your algorithmical capabilities; and being able to develop new algorithms is not always necessary (though always useful) for a programmer. So you can have lots of programming experience and still not be too good at algorithms.
But it is important for Facebook - so that's what they test.
Well, its certainly more fair than giving puzzle/coding questions during an interview. This way you are under no pressure and can work on your own machine in your own time.
Facebook seems to be following the same trajectory that Google did. I remember ~10 years ago Google used to put out such puzzles; if you solved them, your chances of getting hired at El Goog went up significantly.
In another, say, 5 years, expect to hear about Facebook giving out massive retention bonuses to top engineers who are defecting en masse to a hot new startup... :-D
Here is why the puzzles can be very effective, especially for a company in no hurry to hire:
1) The people who submit them are most likely interested in your company, took the time to solve the problem, and have a mind that works well. That already saves a lot of time screening people you wouldn't want for those top positions.
2) It attracts other smart people because you wouldn't refer puzzles to stupid people -- notice how we posted it on Hacker News. On a similar note, if you google for Node.js like I did, you'll find a sponsored result from Meebo offering you to apply to their "secret jobs!" -- because not just anyone searches for Node.js, but rather people who are interested in the new technology, which they are probably using or looking into.
3) Psychology -- people feel like they want something they worked towards. They committed time to facebook, so they will take it more seriously, and when someone from facebook talks to them, and asks them about their background AFTER solving the puzzle, they will feel a sense of accomplishment and engage back.
4) Notice how many of these puzzles have specified the exact outputs. They can screen the initial applicants with an automated test suite to see how well they did. Cheapest first round candidate evaluation ever :)
5) The puzzles are hopefully related to the kinds of architectural and social challenges they actually have to solve at facebook, so this prepares the candidate for that kind of thinking. If the candidate doesn't like thinking in this way, perhaps it's better to find out as early as possible, and before even SPEAKING to the candidate is pretty early!
If anything I would definitely set this kind of thing up for the top (architectural, etc.) development positions at facebook. They were recently named the best place to work at in 2010, so they can afford to do this.
I contacted the like a little guys and they sent me back 2 puzzles before they would even speak to me. The first one was dead simple and took about 14 seconds to write the code and another 7 for it to run and give me the answer.
"A 7 digit number consists of 7 distinct digits (from 0..9 ofcourse); The product of the first 3 digits = product of central 3 digits = product of last 3 digits; Find the middle digit."
The next question I did not understand; I just figured I was not smart enough because I have no college and I am just a hacker that makes shit not a "software eng.". I sent it to a friend of mine that teaches Econ. at a top college and he said he had no idea what they were even asking. (see question below)
Given a list of N line segments on the X axis: (x1[i], x2[i]) where i = 1 to N; And then a list of M queries. Each query inputs one x-coordinate and you need to output the number of line segments that overlap this point. Assume M & N are very large. (So O(M*N) is really bad.)
I asked for clarification and got none so I guess they figured i was just too stupid to respond to which is cool but it made me wonder if when people talk about programmers that cant program do they mean people that cant answer these types of questions? I spent 5 or 10 min or it and gave up. But even though I didn't answer this I can code like a MF and if this question had been a programming challenge I think I could have done it.
My point is that companes should really think before sending out stuff like that to potential developers because they might pass up on some really good talent. I am not saying that I am very talented but I do know how to code and build cool products. I made digest.io and it uses clojure, ML, MapReduce to learn about your diet and help manage digestive conditions and it has paying customers that are happy. I made that and it works well so im not a rookie but I still have no idea what that 2nd question is asking.
BTW: Even though i hate these puzzles the FB puzzles are simple and I have always been able to complete them quickly.
They probably didn't answer because if you need clarification on the question, you have no hope of producing the answer. And incidentally it IS a programming challenge. (Which is why the econ prof had no clue.)
You have a collection of N intervals. And a collection of M points (which they call queries). For a given interval and point, that point can be in the interval or not. For each point you are supposed to find out how many intervals it is inside of. And you're supposed to make the code fairly efficient.
From the way you've written it, the intervals look like open intervals. So x1[i] is not in the i'th interval. That is a minor but significant detail, and I expect their test data to check it.
The naive solution is to write a function that takes an interval and a point, and says whether that point is in that interval. Then you just loop over all points and intervals. This works, but the number of times you run that comparison is N * M. Which, if N and M are large, is going to be painfully slow. In fact there is a notation to discuss how slow, and that notation would say O(N * M). They don't want any variant on this solution.
The solution they are probably looking for is O((N + M) * log(N)). One solution is to try to first find and put into sorted form all of the intervals where the answer is going to be constant across the interval, and then do a binary search for each point to find what interval it falls into (and therefore what the answer is for that point).
My guess as to their thinking is that anyone who can't figure out something like this won't have any clue when they cause scalability problems. This matters for larger sites.
If you don't understand any of what I just said, that's a hole in your background. To fix it go off and learn about little-o, big-O, and some basic algorithms. A short list of algorithms to learn could include quicksort, merge sort, hashing, binary search and how a BTree works. That combination will solve most problems pretty easily.
I really like these puzzles. After you get through the first few trivial ones. The submission process is a little frustrating in that you have no idea if your code failed because it's wrong or because it simply took too long.
Taking too long is a real problem with a few of the puzzles (eg breathalyzer). If you read the comment threads there are some astoundingly fast solutions out there. My C breathalyzer solution was pretty quick but I was running it on an Ubuntu VM running inside Windows 7 and that did impact performance (particularly I/O). I've been meaning to run it on a real Ubuntu setup but haven't gotten around to it.
Anyway it all became moot as I ended up getting a job at Google but I did find it an interesting exercise.
Meh, perhaps I've grown crotchety, but I'm not jumping through hoops for you (theoretical employer), sorry. I can solve puzzles just fine, but I'd rather spend the holidays implementing new PostgreSQL driver.
I'm confused, what exactly do they mean by this bit, "If you compressed your solution, any Makefile/build.xml files (and the executable file itself) need to be uncompressed and/or built into the same root directory as the compressed archive itself or your submission will result in a build error."
Are they saying that the archive shouldn't have any directories in it period or that it should all be in one directory?
Sounds like neither. A prebuilt binary (or the makefile and resultant binary) should be at the top level. You could have other files in subdirectories if you liked.
The puzzles posed in interviews at Facebook (and at Google) have a lot less B.S. It's more geared toward data structures/algorithms. Failing to solve these puzzles is a deal breaker.
here's a kind of medium example from Fog Creek: given a list of elements in lexicographical order (i.e. ['a', 'b', 'c', 'd']), find the nth permutation
I'll add that they'll give you a certain amount of guidance if you require it, but beyond a certain point they're just helping you to make it less awkward.
Why have I been downvoted? Facebook suggests to practice with the puzzles linked by OP before registering for Hackercup, so these are very well connected.
I hacked up a simple script to automate submissions (https://gist.github.com/757221). It handles a single file per puzzle, so an executable or an archive.
[+] [-] michaelchisari|15 years ago|reply
I think one of the reasons I don't do well on these is because my brain doesn't seem to work well for hypotheticals. I need real world use cases or else it's exceedingly difficult for me to work out a solution for a problem that is too abstract.
Maybe I'm unique amongst other programmers with my level of experience. It's possible that other programmers love doing puzzles like this, but I tend to get discouraged if I'm looking at a company, and they use tests and puzzles to gauge my capabilities.
Especially (and I wouldn't accuse Facebook of this, but it happens much too often), if those tests and puzzles are substitutes for looking at the massive amounts of code I've written.
[+] [-] deadc0de|15 years ago|reply
[+] [-] endtime|15 years ago|reply
I don't mean to imply that you are unable to think, of course - the puzzles are surely an imperfect heuristic - but that's my understanding of their aim.
[+] [-] bfung|15 years ago|reply
If the questions were more like "How would you move Mt. Fuji", then that's certainly hypothetical.
[+] [-] bbarthel|15 years ago|reply
If you consider the fact that:
- It is unlikely I am well-versed in the problem domain of your code,
- I am unlikely to be aware of external design constraints or coding pressures,
- I am probably going to randomly select the worst section of code to review,
- I have no context for how the code evolved
the chances that I walk away with a negative impression are high enough that it should give you pause. If I do manage to walk away with a positive impression of your code, it will be offset by the perception that you believe your time is more valuable than mine (why else would you send me a massive amount of code and ask me to review it to determine your suitability for a position) - and you still haven't answered the other big question I need answered which is whether you are a good "fit" for the team from a personality/cultural perspective.
If you really want to impress me, go ahead and send me a list of your projects and contributions and then slice a relevant sample of code from it. Describe what the problem was and how you solved it so I can understand the context. Try to make it relevant to the position, but failing that describe how you could utilize that experience in the relevant domain. Keep it small enough that I can review it in under an hour or two.
Is it a lot more work for you? Absolutely, but if you do this I guarantee you I will look at your code and will likely call you for an interview because you are demonstrating a high level of competence and professionalism while still respecting my time and needs.
[+] [-] dancavallaro11|15 years ago|reply
[+] [-] prostoalex|15 years ago|reply
However, that leaves a whole lot of candidates out of the picture. Faced with limited recruiting resources, puzzles are about the next best thing to serve as a recruiting filter. Plus some people send them in without being told to, which is usually a plus, as it implicates coding in their spare time is something they enjoy doing.
[+] [-] egor83|15 years ago|reply
But it is important for Facebook - so that's what they test.
[+] [-] jamii|15 years ago|reply
[+] [-] ajays|15 years ago|reply
In another, say, 5 years, expect to hear about Facebook giving out massive retention bonuses to top engineers who are defecting en masse to a hot new startup... :-D
[+] [-] wh-uws|15 years ago|reply
[+] [-] EGreg|15 years ago|reply
1) The people who submit them are most likely interested in your company, took the time to solve the problem, and have a mind that works well. That already saves a lot of time screening people you wouldn't want for those top positions.
2) It attracts other smart people because you wouldn't refer puzzles to stupid people -- notice how we posted it on Hacker News. On a similar note, if you google for Node.js like I did, you'll find a sponsored result from Meebo offering you to apply to their "secret jobs!" -- because not just anyone searches for Node.js, but rather people who are interested in the new technology, which they are probably using or looking into.
3) Psychology -- people feel like they want something they worked towards. They committed time to facebook, so they will take it more seriously, and when someone from facebook talks to them, and asks them about their background AFTER solving the puzzle, they will feel a sense of accomplishment and engage back.
4) Notice how many of these puzzles have specified the exact outputs. They can screen the initial applicants with an automated test suite to see how well they did. Cheapest first round candidate evaluation ever :)
5) The puzzles are hopefully related to the kinds of architectural and social challenges they actually have to solve at facebook, so this prepares the candidate for that kind of thinking. If the candidate doesn't like thinking in this way, perhaps it's better to find out as early as possible, and before even SPEAKING to the candidate is pretty early!
If anything I would definitely set this kind of thing up for the top (architectural, etc.) development positions at facebook. They were recently named the best place to work at in 2010, so they can afford to do this.
[+] [-] p01nd3xt3r|15 years ago|reply
"A 7 digit number consists of 7 distinct digits (from 0..9 ofcourse); The product of the first 3 digits = product of central 3 digits = product of last 3 digits; Find the middle digit."
"Middle Number: 2" "Set: 1892463" "Common Products: 72"
The next question I did not understand; I just figured I was not smart enough because I have no college and I am just a hacker that makes shit not a "software eng.". I sent it to a friend of mine that teaches Econ. at a top college and he said he had no idea what they were even asking. (see question below)
Given a list of N line segments on the X axis: (x1[i], x2[i]) where i = 1 to N; And then a list of M queries. Each query inputs one x-coordinate and you need to output the number of line segments that overlap this point. Assume M & N are very large. (So O(M*N) is really bad.)
I asked for clarification and got none so I guess they figured i was just too stupid to respond to which is cool but it made me wonder if when people talk about programmers that cant program do they mean people that cant answer these types of questions? I spent 5 or 10 min or it and gave up. But even though I didn't answer this I can code like a MF and if this question had been a programming challenge I think I could have done it.
My point is that companes should really think before sending out stuff like that to potential developers because they might pass up on some really good talent. I am not saying that I am very talented but I do know how to code and build cool products. I made digest.io and it uses clojure, ML, MapReduce to learn about your diet and help manage digestive conditions and it has paying customers that are happy. I made that and it works well so im not a rookie but I still have no idea what that 2nd question is asking.
BTW: Even though i hate these puzzles the FB puzzles are simple and I have always been able to complete them quickly.
[+] [-] btilly|15 years ago|reply
You have a collection of N intervals. And a collection of M points (which they call queries). For a given interval and point, that point can be in the interval or not. For each point you are supposed to find out how many intervals it is inside of. And you're supposed to make the code fairly efficient.
From the way you've written it, the intervals look like open intervals. So x1[i] is not in the i'th interval. That is a minor but significant detail, and I expect their test data to check it.
The naive solution is to write a function that takes an interval and a point, and says whether that point is in that interval. Then you just loop over all points and intervals. This works, but the number of times you run that comparison is N * M. Which, if N and M are large, is going to be painfully slow. In fact there is a notation to discuss how slow, and that notation would say O(N * M). They don't want any variant on this solution.
The solution they are probably looking for is O((N + M) * log(N)). One solution is to try to first find and put into sorted form all of the intervals where the answer is going to be constant across the interval, and then do a binary search for each point to find what interval it falls into (and therefore what the answer is for that point).
My guess as to their thinking is that anyone who can't figure out something like this won't have any clue when they cause scalability problems. This matters for larger sites.
If you don't understand any of what I just said, that's a hole in your background. To fix it go off and learn about little-o, big-O, and some basic algorithms. A short list of algorithms to learn could include quicksort, merge sort, hashing, binary search and how a BTree works. That combination will solve most problems pretty easily.
[+] [-] tim_sw|15 years ago|reply
[+] [-] kqr2|15 years ago|reply
http://www.quora.com/challenges
[+] [-] cletus|15 years ago|reply
Taking too long is a real problem with a few of the puzzles (eg breathalyzer). If you read the comment threads there are some astoundingly fast solutions out there. My C breathalyzer solution was pretty quick but I was running it on an Ubuntu VM running inside Windows 7 and that did impact performance (particularly I/O). I've been meaning to run it on a real Ubuntu setup but haven't gotten around to it.
Anyway it all became moot as I ended up getting a job at Google but I did find it an interesting exercise.
[+] [-] kingkilr|15 years ago|reply
[+] [-] unknown|15 years ago|reply
[deleted]
[+] [-] pmorici|15 years ago|reply
Are they saying that the archive shouldn't have any directories in it period or that it should all be in one directory?
[+] [-] frou_dh|15 years ago|reply
[+] [-] siddhant|15 years ago|reply
[+] [-] alexgartrell|15 years ago|reply
here's a kind of medium example from Fog Creek: given a list of elements in lexicographical order (i.e. ['a', 'b', 'c', 'd']), find the nth permutation
I'll add that they'll give you a certain amount of guidance if you require it, but beyond a certain point they're just helping you to make it less awkward.
[+] [-] admp|15 years ago|reply
[+] [-] admp|15 years ago|reply
[+] [-] blhack|15 years ago|reply
[+] [-] siddhant|15 years ago|reply
[+] [-] prostoalex|15 years ago|reply
It's automated grading, so it's nitpicky about the submission format, etc.
[+] [-] ot|15 years ago|reply
[+] [-] palish|15 years ago|reply