4 ms·
Personally I feel this question ranks low on a quality scale. Too many moving parts and too many variables. There’s a million different reasons for why they co
by ed25519FUUU 5y ago
Personally I feel this question ranks low on a quality scale. Too many moving parts and too many variables.
There’s a million different reasons for why they could bomb it and a million different ways they could succeed at it and none of those reasons might be evident to the reviewer.
- sverhagen 5y agoI don't know. You seem, like others in the thread, focused on "implement 'mult' as age times parameter value", but the goal of the exercise seems much more around: what's your process of going into a code base, asking the right questions, making some good observations by yourself, and not getting stuck. It'd be interesting to hear from the original interviewer if they even cared about how well the solution ended up working, or if the candidate's ability to demonstrate understanding about the (presumably unfamiliar) code base was more important to them.
- ankrgyl 5y agoYou hit the nail on the head. We explicitly did not care about how "well" the solution was written (some solutions were very surgical, others involved a lot of copy/pasta, some folks wrote very detailed comments, etc.), although we did point out and ask you to fix solutions that were incorrect. For example, some candidates implemented "mult" as "add" in a loop, with the row lock acquired and released in each iteration. This solution is vulnerable to a data race if another user concurrently updates the value.
- jwmoz 5y agoCan you explain why some would go down this loop route? I don't know C but the obvious solution to me is what you posted.
- sverhagen 5y agoIt seems a simple way of building the "mult" solution as a composition of the existing primitive(s), here "add". But agreed, that I would not find the tradeof acceptable either.
- Sohcahtoa82 5y agoForget the locking and data race problem...I think about the massive performance problem. It turns multiplication into O(n) instead of O(log n). `mult 2000` would take 2000 times longer than `mult 2`. Imagine being able to DoS a server just by asking it to multiply two numbers.
- jseban 5y ago> This solution is vulnerable to a data race if another user concurrently updates the value. And this, of course, they are expected to understand in an unfamiliar code base with 3 hours total for the whole task. LOL
- FartyMcFarter 5y agoYou don't need to see the rest of the codebase to realise that's probably wrong. In any codebase, locks only apply to the scope they're in.
- jseban 5y agoThe key word here being "probably".
- FartyMcFarter 5y agoYes - so the safe thing to do is to put the lock outside the loop. Anyone experienced in multithreading will instinctively know this is the correct alternative for any codebase (and it performs better too).
- maccard 5y agoNo, not knowing that is a fundamental misunderstandings of either locks or scope. Depending on the role and job level that may be table stakes.
- jseban 5y agoI agree, there's a million things that can go wrong just in installing, setting up and compiling the project. I see losing a lot of good candidates here because they happened to have the wrong version of some library installed..
- sakras 5y agoThey are given a small AWS instance to ssh into, everything is already set up there. There’s a makefile already prepared that will build it.
- db48x 5y agoThis type of question definitely hinges on having a pre–prepared build environment. The author of the blog even noted that getting the build environment set up was not part of the test.