3 ms·
(Small business owner): I prefer the "write me a function that squares a number" approach as the big filter. If they cannot do it, stop right there. If they wri
by dhsysusbsjsi 5y ago
(Small business owner): I prefer the "write me a function that squares a number" approach as the big filter. If they cannot do it, stop right there. If they write it and struggle a bit, stop there. If they write it at a normal or fast speed, continue. If they write an inlinable generic function that accepts anything that can be multiplied - things are looking really good.
- romanhn 5y agoInteresting. My signal from a generic function is that this person tends to overarchitect, if my request was about squaring numbers specifically.
- exac 5y agoSome people love asking interview questions where they don't state all the requirements, so I suppose the idea is to see if the candidate can discover the "hidden criteria". This also makes more sense in a language where number types need manual casting.
- nurettin 5y agoYou can actually train these people by making them create quick POC projects until they become practical programmers. I would take the overarchitechting person.
- xmprt 5y agoIf I heard this question, I'd be more confused than anything. The answer seems like it's just return x*x but I'd probably be more interested in why squaring numbers is so important that it needs a special function. Maybe I'm supposed to implement a BigInteger class or something like it...
- Jare 5y ago> why squaring numbers is so important that it needs a special function I've had pow2() in pretty much every codebase I'd worked on, ever. pow2(x1-x0) looks nicer and less error prone than (x1-x0)*(x1-x0), and less verbose and distracting than first separating to a local var as dx = x1-x0
- toxik 5y agoWhat about using an actual vector library like Eigen? I wouldn’t dream of reimplementing basic maths like that.
- praptak 5y agoYou are almost certainly better off just writing x*x whenever you need a square. A good programmer would point this out.
- deleted 5y ago[deleted]
- jstx1 5y agoOkay, let's role play this. Here's my Python solution: def square(n): return n**2 As a well prepared candidate, it took me seconds to write this. What did this tell you about me? Did I do anything wrong and if yes, what did you expect to see instead? What does this score out of 10 and why?