5 ms·
I'd find this question frustrating because it feels like a trap. I was looking for the trick -- was I missing something in the question that made the obvious ap
by notreallyserio 4y ago
I'd find this question frustrating because it feels like a trap. I was looking for the trick -- was I missing something in the question that made the obvious approach untenable? No, the answer is simple, just add a way to multiply numbers with the multiply operator.
- melony 4y agoAnd correctly dealing with arithmetic overflow.
- Syonyk 4y agoIt's "Advanced FizzBuzz." "Can you understand a complex code base, figure out how to zoom in on the section of interest, and add a function?" Far, far too many people interviewing for coding positions can't do that. Though I question how many could whip out FizzBuzz in 5 minutes and would then fail the more complex version. At some level, either you can code, or you can't. And, importantly, at some point in your career (if you go down the standard management track), you will typically lose the ability to code. If you've not done it in 5 years, you probably can't do it, in a practical sense. Not that you can't re-learn, but you can't just jump into a coding interview and ace it, either. If you find yourself at a point in your career where coding interviews are a thing, "having a side hobby project that requires coding" is a very useful way to be really quite good at coding interviews. Plus, if it's your hobby project, there's no "Hrm... can I talk about that?" sort of problems when you're asked about a time you X'd with Y. You can talk about your personal hobby project absolutely as much, and in depth, as you want.
- mikeryan 4y agoThis isn’t an “Advanced FizzBuzz” if it takes three hours or even one hour. The whole point of a FizzBuzz question is that it’s a fast, like 2-3 minutes fast, heuristic for separating the wheat from the chaff and this isn’t that at all. At some point it’s no longer a FizzBuzz and just a coding challenge. Even the author’s answer reflects that (though he calls it a FizzBuzz) I don’t know a thing about memcached internals but, as presented here, with the potential encoding and concurrency issues means that there’s likely levels to the complexity here that will likely take someone quite a bit of time to resolve if they’re not familiar with memcached internals. But again memcached and even C++ isn’t my thing. ¯\_(ツ)_/¯
- hoten 4y agoThe problem is simpler than all that. There already exists a function that does the exact thing the question asks for, handling all the atomicity complexity. What this comes down to is can the candidate: figure out how to build the project, grep to existing implementation and copy, paste, change a plus to an asterisk. And also, can they articulate the work-to-be-done this simply. I've never seen the first item in that list tested in an interview and .. I don't hate the idea.
- mikeryan 4y agoWhat this comes down to is can the candidate: figure out how to build the project, grep to existing implementation and copy, paste, change a plus to an asterisk. And also, can they articulate the work-to-be-done this simply. While that’s the gist of it, it hardly seems that’s quite enough from the author’s solution, nor should it be enough for an interviewer. The question isn’t how to write, or copy paste a function but how to add the command interface as well which, if one doesn’t know memcached, can be more complex then the function itself and isn’t covered by this trite an answer. https://quuxplusone.github.io/blog/2022/01/07/memcached-interview-solution/ https://quuxplusone.github.io/blog/2022/01/07/memcached-inte...
- astee 4y agogrep for "incr" and add "mult" below it ¯\_(ツ)_/¯
- Syonyk 4y ago"Jumping into a non-familiar codebase and being useful" is literally what someone is considering paying you for. Years ago, I got tired of some owners of a company I worked for hiring bench techs (small business IT support and such) who'd clearly never opened a computer before (I don't know why, but as the closest person I couldn't focus on any of the work I was supposed to do when constantly being interrupted by bench techs), so I "broke" a scrap computer as an interview problem, rather extensively. RAM wasn't seated, a PCI card wasn't fully seated, I think the power switch was halfway pulled off (enough that it didn't work but was visibly wrong), and I did some terrible things to the partition tables as well. The goal, which it succeeded quite well at from my point of view, was to see where a possible bench tech's skills ended, then help them through. If you'd worked on computers a bunch, and one wasn't powering on, "reseating stuff" was a useful enough response, which would either clear the corrosion on some pins or ensure everything was actually planted in place, which would render this machine booting (after you pushed the power button connector back in), and let me observe what you did with some weird boot errors. There were Windows and Linux environment boot DVDs laying around, so, pick what you know. The result of this was that our next bench tech hire had the skills to do stuff himself, and generally left me alone to do the stuff I was trying to get done.
- teraflop 4y agoThis might just mean that you've been overly conditioned to expect bad interview questions that do rely on a "trick". But if so, I'm sure you're far from the only person in that position. Would you be less frustrated if it came with a disclaimer, along the lines of "this is not a trick question"? (I realize this might sound sarcastic, but I'm serious. I think the way interview questions are presented is very important, and often overlooked.)
- notreallyserio 4y ago> Would you be less frustrated if it came with a disclaimer, along the lines of "this is not a trick question"? Definitely. That would make it more clear it's about SE and not stupid brain tricks.
- tantalor 4y ago> make it more clear it's about SE Your first clue is it's an interview for a software engineering job.
- andrewingram 4y agoI’ve had plenty of interviews for software engineering jobs where I’ve been asked trick questions. Like “explain why this code is broken” when it’s not actually broken.
- sverhagen 4y agoI've not been conditioned to expect bad interview questions, so I'm gonna ask: in what way would/could this be a trick question?
- 542458 4y agoI was waiting to see a weird gotcha about multiplication not being atomic or something. Actually, question for people with more low-level knowledge than me: is that solution atomic?
- dist1ll 4y ago> that made the obvious approach untenable What's the obvious approach? You do have to dig into the source of memcached and understand some internals. With good use of grep and vim it can be done quite quickly, but I wouldn't call it obvious.
- notreallyserio 4y agoThe obvious approach would be to copy the code for an existing function, I think.
- davidw 4y ago"They gave him an intelligence test. The first question on the math part had to do with boats on a river: Port Smith is 100 miles upstream of Port Jones. The river flows at 5 miles per hour. The boat goes through water at 10 miles per hour. How long does it take to go from Port Smith to Port Jones? How long to come back? Lawrence immediately saw that it was a trick question. You would have to be some kind of idiot to make the facile assumption that the current would add or subtract 5 miles per hour to or from the speed of the boat. Clearly, 5 miles per hour was nothing more than the average speed. The current would be faster in the middle of the river and slower at the banks. More complicated variations could be expected at bends in the river. Basically it was a question of hydrodynamics, which could be tackled using certain well-known systems of differential equations. Lawrence dove into the problem, rapidly (or so he thought) covering both sides of ten sheets of paper with calculations. Along the way, he realized that one of his assumptions, in combination with the simplified Navier-Stokes equations, had led him into an exploration of a particularly interesting family of partial differential equations. Before he knew it, he had proved a new theorem. If that didn't prove his intelligence, what would? Then the time bell rang and the papers were collected. Lawrence managed to hang onto his scratch paper. He took it back to his dorm, typed it up, and mailed it to one of the more approachable math professors at Princeton, who promptly arranged for it to be published in a Parisian mathematics journal. Lawrence received two free, freshly printed copies of the journal a few months later, in San Diego, California, during mail call on board a large ship called the U.S.S. Nevada. The ship had a band, and the Navy had given Lawrence the job of playing the glockenspiel in it, because their testing procedures had proven that he was not intelligent enough to do anything else."
- jrib 4y agoquote from Cryptonomicon by Neal Stephenson
- josephg 4y agoMedical people talk about this problem as "differential diagnosis". There can be multiple reasons why some symptom is exhibited (in this case, failing the interview). Its not enough to know that the interview question was failed - you also want to know what happened. A much more common example is that (particularly young) candidates tend to make job interviews into big, stressful things in their head. Then they don't sleep properly the night before, and during the interview they can't think creatively or access deep memories (which are both well known symptoms of stress). They can't answer your questions. You think its because they don't know, but actually the problem is that they're too stressed to think at all. Long programming questions work great for my anxiety because I can zen out while I'm programming and forget the interviewer is there. But everyone is very different with this sort of thing. The more general way to work around this problem is to listen and pay attention to the candidate. If you asked "Lawrence" in this story what he was thinking about during this interview, he'd tell you about fluid dynamics and partial differential equations. That tells a story. Another candidate will tell you that they felt really awkward programming through an SSH connection because they're used to Visual Studio. Or how they really do (or don't) like some aspect of the programming style on display. Or how (to crib from another commenter) the programming was easy enough, but they're worried that doing so introduces a race condition between atomic multiply and add instructions if they're interleaved. And they hate doing the work because they feel like they're introducing a bug. None of that really helps with stress bunnies, but you learn so much about what sort of employee they'll be by asking.
- Tao331 4y agoThe only trick I see is that the copy-paste-find-replace solution is preferable to the one that attempts to maximize reuse.
- jimbokun 4y agoI think the test is whether you can grep an unfamiliar code base to find the implementation of existing functionality, understand it, and modify it to add very similar functionality. Like do the commands have to be registered somewhere? Is it a string mapping the operation name to a function pointer? A cascading if-then statement? Etc. etc. It's just a test of diving in and understanding existing code in a relatively short amount of time.
- sanderjd 4y agoYears of crappy tricky interview processes have broken our brains.