Slashdot Mirror


Tech-Interview Riddles

An anonymous submitter writes "A computer engineering student at UC Berkeley has made a comprehensive archive of riddles from technical interviews. Very challenging and loads of fun. Also useful for interview preparation."

29 of 747 comments (clear)

  1. "Microsoft was responsible" by siliconshock.com · · Score: 4, Funny

    I believe Microsoft was responsible for popularizing the usage of riddles in interviews

    Yes, but they still have not been able to find anyone who can solve the "why does windows crash" riddle!!

  2. more info... by onby2000 · · Score: 5, Informative

    for more tech interview questions and answers try http://www.techinterview.org/

  3. Why do interviewers use "riddles"? by Turing+Machine · · Score: 5, Insightful

    What's up with using this type of question for interviews, anyway? Sure, they can be fun, but they're perfectly useless as far as telling whether someone can actually write solid code. 9 times out of 10, all they tell you is whether the interviewee has heard that one before.

    To interviewers: Do you really think that the answers to these questions don't spread through the entire department within 15 minutes after your first interview? I realize that "knowing the answer" makes you feel smarter than the prospective employee in some sense, but how about actually doing your job for a change?

    1. Re:Why do interviewers use "riddles"? by MisterBlister · · Score: 4, Interesting
      If you tell me about ARP, DNS, and HTTP and you can name the port numbers and transport layers, that's fine. DHCP, load-balancing, firewalls, SSL, proxy servers, server-side processors, databases, that's all extra credit. If you can't talk about these things, you're not yet ready for a professional career in this industry.

      'this industry', meaning network admins who focus on web sites only, right? Not admins or programmers in general?

      Because I'd have an easy time talking about all of that stuff, but I know people as or more intelligent than I am that wouldn't simply because they haven't been exposed to any of that directly.

      It seems to me your question is flawed. You're asking too much about details that can be learned by any intelligent technical individual in a matter of days. Just because they don't know the answer when you ask it doesn't say shit about how good they might be at the job, especially if the job is something more than simple web admin.

    2. Re:Why do interviewers use "riddles"? by Turing+Machine · · Score: 4, Informative

      The "official" answer (which Microsoft was still using as recently as a couple of years ago, according to some friends of mine who interviewed there) is so the covers won't fall through the hole.

      This answer fails on at least two levels:

      1) There are plenty of manhole covers (or manhole-cover-like-objects) that aren't round. If you've been observant enough to notice this, you fail.

      2) There are plenty of other curves of constant width; an infinite number, in fact. The old Wankel rotary engine used such a shape. Though a circle is the only curve of constant *radius*, that's not the issue. If you know enough math to realize this, you fail.

      Another possible answer is that it makes it easier to roll a heavy cover out of the way. Again, one of the other curves of constant width would do just about as well.

      The REAL answer is that no one knows.

      Personally, I think Microsoft would be better off asking people why using fixed-sized buffers for user input is a bad idea, but hey.....

    3. Re:Why do interviewers use "riddles"? by Latent+IT · · Score: 4, Informative

      Well, crikey. But ask yourself this - if not round, well, what?

      Okay, so you're a guy, and you have to put a hole in the street, and put a cover on it. What shape do you make it? Triangular? Well, uh, why? It's pointy, and can fall through the hole. So you wouldn't do that. Square? Well, you really can't roll it, and TRUCKS have to drive over it, so it'll be heavy, so you'd *want* to roll it, rather than heft it.

      Hey, circles can roll.

      Oh, yeah. And that crap about a Wankel. Why would you want to fiddle around in traffic trying to get it to be oriented properly when a circle HAS a constant radius, as you point out? You can thump it down any old way. Fits!

      So, answer: Because it's just better than any other shape.

    4. Re:Why do interviewers use "riddles"? by cwikla · · Score: 4, Insightful

      The problem with "light bulb" questions is that people tend to like to come up with their own ones, which usually tend to be crappy, or ones, as earlier mentioned, that someone stumped them on, and now they think they are clever for knowing the answer. Even "technical" questions sometimes fall into this one.

      Some experiences in my past:

      A couple of years ago I was asked: How many gas stations are there in the US?

      My answer: I don't know, I'd probably check a search engine.

      After I insisted that I couldn't come up with an answer on my own, I was informed that they were looking for people who "think out of the box" and only people that hazarded a guess made it to level two interviews.

      I laughed, and explained that if someone I was interviewing made up some bullshit answer with absolutely no backing I'd be afraid that would carry over to their real work and it was a silly prerequisite. Knowing where and how to find an/the answer can be even more useful then making up an unfounded answer. Lots of smart people out there. Lots of stuff already been done.

      Hmmm, come to think of it I never did get a second interview.

      Or the time I was asked to come up with a string hash function. So I quickly threw together a loop just adding all the bytes, shifting some bits each iteration. Simple, not great, not perfect, but a decent 10 cent solution. I was then walked through the "correct" answer that covered, number of bits in byte being used, average word length, etc, etc...and told this was the "correct" answer. Researching later, I believe the solution was either in a Knuth book, or was another Microsoft tidbit. But I'm sure the interviewer would have come up with the solution independently given the same question in the interview...

      Finally, my FAVORITE is being asked some hard technical question. You ponder, you falter, and come up with some sort of a solution, but aren't quite satisfied it. Of course the interviewer then informs you it's a problem they are currently working on and they are trying to come up with something themselves. Seems like you should be paid contractor rates at least for that part, no?

      I find that having people talk about their work, explain what they did, and WHY they did it pretty much can measure a candidate against your bullshit meter in a matter of minutes.

    5. Re:Why do interviewers use "riddles"? by JamieF · · Score: 4, Insightful

      >You can focus on code centric questions, but will that person still
      >perform well if they move to writing specs, managing people, or
      >developing an advertizing plan?

      Good, experienced developers should be really good at writing specs since they know what level of detail is needed. In fact I think they stand a better chance of writing an implementable spec than an Analyst who has never coded.

      As for managing people or developing an advertising plan, those are totally different skill sets from development. Have you ever worked with a manager who totally sucked as a manager but was a really smart developer? I have, several times. It's painful, and it drives home the point that managing well takes skill.

      The idea that you can just dump a bunch of smart people onto any problem and outperform a bunch of experienced people who aren't quite as smart strikes me as terribly naive. Or, in Microsoft's case, conceited: it's pointless to learn from the past because we're all smarter than they were. So we'll get it right the first time and come up with a more clever solution on our own than if we just READ A DAMN BOOK. And so you get badly designed, bug-ridden software that solves problems that were already solved better 10 years beforehand. Oops.

      Perhaps if you're truly working on something novel it would clearly be better to have smart people than not smart people, but in that case it's not possible to hire for experience anyway so it's not germane to this discussion.

      You want good ads, hire someone who's good at doing ads. You want a good manager, hire a good manager. Or, train someone who is partway there. But don't just throw bright young people at any task and assume that they'll do better than an experienced person. I've worked in companies where that was the explicit philosophy and it's a disaster. After a few nightmare projects that smart manager might figure out some techniques that a less smart manager took a lifetime to develop, but that less smart manager wrote it all down in a book 30 years ago. Don't you wish the smart manager had read it BEFORE their first project as a manager?

      Show me a chess club that can beat Marines at paintball and maybe you'll change my mind.

    6. Re:Why do interviewers use "riddles"? by daoine · · Score: 4, Interesting
      My answer:I don't know, I'd probably check a search engine.

      Funny, I had a similar interview for a question at a consulting company. It was basically another 'estimation' type question.

      My first answer was that I'd check google. They didn't like that at all, saying that they needed to be able to come up with these stats quickly, and that an employee shouldn't have to rely on anything. I said that part of solving a problem is knowing when to NOT reinvent the wheel and using information that's readily available.

      Didn't get a second interview either. Not even a phone call saying thanks for interviewing.

      Personally, I love interview puzzles and riddles. But I HATE people who refuse to accept an answer different from the one they have written down. That's not the point. An interview puzzle's supposed to give you an idea of how a person solves problems...not how quickly they solve it the "right" (*snicker*) way.

    7. Re:Why do interviewers use "riddles"? by pongo000 · · Score: 4, Interesting

      Those points are true if you're hiring a contractor to come in, do a job, and get out. They are not true if you're hiring a flexible team player who is going to handle a demanding job which is guranteed to throw new challenges on a daily basis.

      Please. Do you really think some silly-ass riddles will separate the wheat from the chaff? In a previous life, I was an air traffic controller (9 years). I was thrown new challenges several times an hour. I don't recall riddles being asked on my interview.

      I can tell you, however, that the three months of indoctrination in Oklahoma City was a head game unto itself. The point being it took three months to sort the psychologically strong from the weak. I seriously doubt a few puzzles on an hour-long interview is going to tell you much of anything.

  4. One of my favorites by Reality+Master+101 · · Score: 5, Interesting

    I used to put this one on my programming tests. It's actually shocking how many people get it wrong...

    You are writing a parser that reads a C program and translates all the variable names into new names of the form "VAR######", where ###### is an integer incremented for each unique variable name. Discuss what is needed for the case where the C program already contains a variable of the form "VAR######".

    --
    Sometimes it's best to just let stupid people be stupid.
    1. Re:One of my favorites by Reality+Master+101 · · Score: 4, Interesting

      You the man! Here is your honorary degree.

      Now, for this honorary Ph.D., answer this question (another one of my favorites):

      You have a 32 bit unsigned integer. You want it to be really reliable, so you store it three times (triple redundancy). Write a subroutine that takes three unsigned, 32 bit integer arguments, and returns a single unsigned 32 bit integer that is constructed by having the bit in each bit-position "vote" for the corresponding output bit (e.g. if at least two of the low-order bits in the passed in arguments are 1, then the low-order bit in the output is a 1).

      Hint: There's an easy, fast way, and there's a hard, slow way. I'm looking for the easy, fast way.

      I actually got this question on an interview once (and of course figured out the right answer :) ).

      --
      Sometimes it's best to just let stupid people be stupid.
    2. Re:One of my favorites by Henry+V+.009 · · Score: 5, Funny

      How is the view from the Ivory Tower?

      Here is what actually happens:

      I have 25 minutes to write out the parser. It's 11:35am September 30th, and our guys in marketing promised that C-Checker 5500 would be out in September. If its not finished on time, management will start complaining that we need to double the number of programmers or something crazy like that.
      The hard part of the problem is variable identifiction. Have to look up the standard keywords again and type them in, and make allowance for a couple of other things.
      After finishing that part I've got 10 minutes left.
      Now I zip through with a little routine that takes the first varible it comes across and replaces it and all future occurences of it with VAR#1, and so on.
      So I run my program on the main development project to test it out.
      I press compile on the modified program. Cherchunketa, cherchunketa --- boom! Compilier error messages out the wazoo.
      Who the hell named his loop counter VAR#37534? Goddamn that bastard! Who the hell does something that crazy?
      Now I have 3 minutes to implement the fix. Do I write in the simple check algorithm that all the CS students you managed to trick came up with?
      Hardly, I rename the thing to VARXY750#XXXXXX, and wait for a bug report.

      As for the triple redundancy problem. Before you start going into your ANDs and ORs and wherefores, there are a few things to keep in mind. First off, if its really important, you need some non-local copies. What if there is a hard-drive crash? Or a nuclear war? The internet will still be around even if the main office is a glassed over glowing area in the North Western U.S. If it's important enough for triple redundancy, it's important to survive any forseeable catastrophe isn't it? So now you have to encrypt the numbers coming and going, and sign it, to keep the hackers from fooling you.

      And so what is the easiest way to implement all this? Simple--there is no simple way. It'll take a lot of work. So you might as well throw your computer out of the window and tattoo the number to the back of your hand.

    3. Re:One of my favorites by The+Cat · · Score: 5, Insightful

      I've caught some really bright people with it.

      So, what's the point again? Proving people aren't as bright as they think? Making people sit there and squirm because they really need a job, are nervous anyway, and have some "three cups and a white marble" puzzle standing between them and feeding their kids?

      I don't get it. My first question would be "why don't we just hire the bright people and get back to work?"

  5. Re:These are pretty easy by RadioheadKid · · Score: 5, Funny

    My first thought was, where are the answers. My second thought was, thank god I have a job.

    --
    "Karma can only be portioned out by the cosmos." -Homer Simpson
  6. TWO CONDOMS, THREE WOMEN by 0xdeadbeef · · Score: 5, Funny

    A man would like to have safe sex with three women, any of whom may be carrying an STD. Given two condoms, how can he do so, while ensuring that no STD is passed from one woman (or possibly himself) to another (or to himself)?

    This is a common situation on the job. Who says riddles aren't relevant in interviews?

    1. Re:TWO CONDOMS, THREE WOMEN by jred · · Score: 5, Funny

      Ok, I like the other guys' answer, about wearing both & flipping it. But I think that would suck. I don't mind wearing one, but two at once just isn't going to work for me. So I use condom 1 on girl 1, condom 2 on girl 2, meanwhile having sent girl 3 to the store to get more condoms :)

      --

      jred
      I'm not a mechanic but I play one in my garage...
    2. Re:TWO CONDOMS, THREE WOMEN by Elwood+P+Dowd · · Score: 5, Interesting

      Wear one condom. Wear the 2nd one outside the first one. Have sex with 1st woman.

      Remove the 2nd, outer condom, have sex with the 2nd one with just one condom (the 1st one).

      Fold the just removed condom inside out and wear it over the 1st one. Have fun with the last woman.

      Who says that you can't use "Economic engineering" knowledge on bed, :-)


      If this is the correct answer, then I would be at an unfair disadvantage answering this question. Because I *listened* in sex ed when they said that using two condoms at the same time was dangerous. It's too likely that air will get caught between the condoms. Some parts will stick and some parts will stretch, leading to two broken condoms.

      --

      There are no trails. There are no trees out here.
    3. Re:TWO CONDOMS, THREE WOMEN by Anonymous Coward · · Score: 5, Funny

      Easy, its just a riddle... Very unlikely to occur in a real world situtation. It seems you guy are actually planning what you would do in such an event!

      "Oh no, 3 horny women and only 2 condoms...Thank god I read slashdot".

  7. Common Interview Question: by wirefarm · · Score: 5, Funny

    "What will it say in the newspaper about you when you die? In effect, write your own obituary:"

    All-time best answer:
    "Gunman shoots nine, then self."

    My friens Marc *swears* he said this in an interview.

    Cheers,
    Jim in Tokyo

    --
    -- My Weblog.
    1. Re:Common Interview Question: by Sheridan · · Score: 4, Funny
      (this isn't one of mine - its a variant on a .sig either here or on usenet soemwhere):-

      "Where did he get the plutonium?"

  8. Microsoft interview questions by MillionthMonkey · · Score: 5, Funny

    You have a monopoly in a given market. A company creates a groundbreaking product and establishes a new, completely different market. Assuming you cannot buy the company, how do you smash it and extend your monopoly in the old market to the new one?

    How would you go about designing an email client that executes any code that is sent to it?

    If you could remove any of the fifty states (thus rendering federal antitrust statutes inapplicable to corporations in that state) which state would you remove and why?

    How would you go about designing an operating system for people who hate computers and who just want to use their machines for pay-per-view entertainment?

    An End User License Agreement (EULA) appears in a window with "I Agree" and "I Disagree" buttons. The text area in which the EULA appears is eighty columns wide. How many lines of text can be included in the EULA before a computer that just meets your system requirements is unable to load it into memory?

    At a fork in the road between two cities, you see 2 people. One always tells the truth, and comes from the city of safety. The other person always lies and comes from the city of cannibals, where they will eat you. Which one do you hire to write up licensing agreements for your legal department?

    An Arab sheikh is old and must will his fortune to one of his two sons. He makes a proposition. His two sons will use their computers, and whichever computer gets a blue screen of death first will win the fortune for its owner. During the race, the two brothers do nothing on their computers, neither willing to risk a blue screen of death. In desperation, they ask a wise man for advice. He tells them something; then the brothers immediately jump onto the computers and start installing new hardware, sharing files, and downloading hastily written security updates. What did the wise man say?

  9. Here's the riddle I wish Microsoft would use... by JamieF · · Score: 5, Funny

    "So there's a programmer writing some code, in C. That programmer needs to use a buffer to store some data. How does the programmer write the code such that an unexpectedly large amount of data doesn't overwrite the stack and result in a remote root exploit?"

  10. I know the answer! by benwaggoner · · Score: 5, Funny

    Because the holes are round.

    I mean, really, any other shape wouldn't fit...

    *ducking*

  11. some selected answers: by SlugLord · · Score: 4, Informative

    Some answers from the hard section:

    Criminal cupbearers:
    Let's assume we only have 10 prisoners and that they each drink from up to 512 bottles. Number the bottles from 0 to 999. Prisoner 9 samples 0 to 511. Prisoner 8 samples 0 to 255 and 512 to 999. Prisoner 7 samples 0 to 127, 256 to 383, 512 to 639, etc. (prisoners alternating between sampling and not sampling blocks of wine in decreasing powers of 2 -- prisoner 0 drinks from every other bottle) Now line up the prisoners after onen month and treat corpses as ones and living prisoners as zeros and you have your answer in binary.

    Mysterious Triangle area
    Well, to make a long story short, they're not triangles.

    100 Prisoners and a Lightbulb
    Well if we assume they can all see the bulb every day, they can just toggle the bulb iff this is the first time they've been selected. If the last prisoner has counted the number of times the bulb has been toggled, he can assert that he is the last one to be selected.

    Square Formation
    Move the "notched" piece to teh righth of the current larger square and put the small square piece in the notch. put the larger of the triangular pieces at the top, horizontal edge of the new formation.

    Calendar Cubes
    I like this one. You need all the numbers from 0 through 9 plus 0 through 3. That's 14 faces. You will never need 00 though, so you can remove one of the 0s. Also, you will only ever need the 3 with 0 or 1, so you can remove it from one of the blocks. The solution: the numbers 1-6 on one block, and 7-9 and 0-2 on the other. Yeah it works.

    Mystery Matrix
    4. Entry from row plus Entry from row 2 plus 1 mod 10.

    Fork in the road I
    "is that the city you come from?" If the response is yes, go there, otherwise turn away.

    Fork in the road II
    Assume each person is standing on his respective road. "Is one of you a liar?" Yes means he's a truth teller, no means he's a liar.

    Egg Dropping
    18. Drop from the 10th, 20th, 30th, etc. After it breaks, go back 9 floors and start dropping every floor. You use 18 drops if it can drop from the 98th or 99th floors.

    Greedy Pirates
    It's not apparent to me that this is the intended answer, but "Throw pirates 3 and 4 overboard and divide up the rest between 1,2, and 5. Pirates 1 and 2 will agree to the largest share, and pirate 5 always has a say after that, since 3 and 4 can't agree to anything, so he's needed for the majority.

    Hmm, well it's getting late so I'll just do one more:
    Card Game
    Bob takes any card over 9. The probability that none will show up is roughly .2 with an average payoff of $5. That means that the probability of getting a face card is .8 with a payoff of 11.5. Using more precise figures, i.e. not .2 and .8, the average payoff is about 10.0857 (706/70)

  12. These tech interview questions are STUPID by JamieF · · Score: 5, Insightful

    Am I the only one who thinks this interviewing technique is retarded?

    Because Microsoft does something most definitely isn't a reason to emulate it. Microsoft isn't exactly known for producing well designed software, nor software that reuses proven patterns or algorithms that solved known problems 20 years ago. Better to hire a bunch of 21 year old college grads who can solve word problems from 8th grade algebra, and pretend that Microsoft invented computers! Whee.

    When I hire developers I want them to be good developers, not promising young interns. My interview questions typically involve technology questions, process questions, some theoretical PROGRAMMING questions, and some social / communication questions. I'm not saying that hiring smart people is a bad idea, but ignoring skills and only looking at generic problem solving ability is a recipe for unbelievably bad code. It's like hiring musicians based on measured hearing sensitivity and reflexes. OK, maybe that matters if you want to figure out which 5 year old is going to be a prodigy, but hand them an instrument and the noise that comes out is going to sound like ASS.

    Examples of things that "smart" developers I've worked with before have totally missed:
    - the existence of more efficient data structures than arrays
    - generalizing code into reusable chunks (functions, objects, whatever)
    - regular expressions
    - the difference between "client" and "server"
    - the reason for using descriptive variable names
    - collection libraries with built in sorting ("whatcha workin' on?" / "coding up a quicksort algorithm" / "in a J2EE app!?!?")

    You can't just get this from reading a book, either, although that definitely helps. You have to have some degree of EXPERIENCE too: at least a few projects, and some awareness of things like performance tuning, security, coding for maintainability, etc.

    I would use these "tech interview questions" only for hiring interns or recent college grads where the expectation is zero experience, zero clue, zero skill, and a correspondingly low salary. After all you're investing in someone. But for someone that commands a market rate developer salary in the high five figures, screw the brain teasers - just spend a couple of hours grilling them on skills, experience, discipline, etc. They will respect you big time in return because they know when you extend an offer that they won't be working with a bunch of dumb-asses who can get the explorers across the river without being eaten by the headhunters but who can't code their way out of a soggy paper bag.

    1. Re:These tech interview questions are STUPID by MeerCat · · Score: 4, Insightful

      Precisely why companies end up with the wrong employees. My usual answer to these questions is "Sorry, the interview ends here, you failed", or (if I feel like baiting them) to "think outside the box" eg the bridge/flashlight/limited time issue "so, one guy is lighter than the others and they realise they can cross together, or they wait til their eyes adjust to the darkness and they're fine, or they check their watch and realise they have more time than they thought". If the interviewer says "no, wrong answer" I tell them they've missed "the big picture" and they need to "free their minds from the imagined constraints", and then ask them what we're doing next...

      On a similar note, I do NOT want to hire staff who can put a list of obscure C++ operators in order of precedence, I want to hire those who say "well, I'd look it up if need be, but to make sure the next guy reading my code doesn't get confused I'd simplify the expressions with braces"... bingo - instant pass !

      Interview questions should be open, not closed.

      --
      T

      --
      I spent a lot of money on booze, birds and fast cars. The rest I just squandered. - George Best
  13. Infuriating,,, by Grape+Shasta · · Score: 4, Interesting
    The thing that drives me nuts is not having the "right" answer to check my answers against. Look at this one, for example:

    willywutang is hanging out on a heavily forested island that's really narrow: it's a narrow strip of land that's ten miles long. let's label one end of the strip A, and the other end B. a fire has started at A, and the fire is moving toward B at the rate of 1 mph. at the same time, there's a 2 mph wind blowing in the direction from A toward B. what can willywu do to save himself from burning to death?! assume that willywu can't swim and there are no boats, jetcopters, teleportation devices, etc.. (if he does nothing, willywu will be toast after at most 10 hours, since 10 miles / 1 mph = 10 hours)

    There's many possible answers, so how do I know if I've got the answer they want? He's in a heavily forested area, so grabbing a log and paddling out around the fire shouldn't be hard. Or he could dig a little moat, though that might not be too effective. So, is there some other, clever answer, I should look for, or am I done? Grrrrrrrrr!

    --

    "I am a cipher, a cipher, wrapped in an enigma, smothered in secret sauce" -Jimmy James
  14. Why I never asked riddles.... by rufusdufus · · Score: 5, Informative

    I did a lot of interviews at MS when I was there, and I quickly learned not to ask riddles. First off, it makes people who don't get them uncomfortable and angry. Second, it doesn't actually show that the person can write software.

    I used a much simpler approach, so simple most people think its silly. But thats the point; nobody leaves the interview thinking they were tricked or duped. I always started with implementation of strcpy(). Half of the candidates failed right there! They took most of the hour to get it right (or not), but were able to see point-blank that they were not ready for the job.
    Next, I would ask about crashing cases, and if they figured out overlapping memory locations, have them write a 'fixed' version. This weeded out another big chunk. After that, I went into some color counting algorithms.
    I stayed well withing the field of what the candidate would expect, and did not try to trick him or make him nervous with off the wall riddles.

    This approach worked great, and didn't leave anyone feeling robbed and abused. The ability to solve riddles *is* an indicator of how smart the person is, but it is *not* an indicator of how good a programmer they will be.