5 ms·
Or you can just learn a simple programming question or two that you can ask them to write the answer to. Example: string itoa(int i) { //convert integer to i
by jswinghammer 16y ago
Or you can just learn a simple programming question or two that you can ask them to write the answer to. Example:
string itoa(int i)
{
//convert integer to its string representation
}
In my experience this will tell you enough about the person's proficiency to make a decision. I've seen so many people fall apart on this question in so many different ways it's not even funny. The ones who get it have all been pretty good hires.
- ddlatham 16y agoHow would you judge their answer if you're not a programmer?
- jswinghammer 16y agoLearn the answer. It's not very long. You can have some followup questions like "How would you test this?" or "What range of values would this work for?". Most of the time people don't even know what range of values can be stored in a 32 bit integer (or even in the general area). It's pretty easy to learn 3-4 facts to know more than the people you don't want to hire.
- jpablo 16y agoLearn the answer. Then you risk rejecting exceptional candidates who didn't come up with the answer that you learned.
- aplusbi 16y agoYou could have someone else set up a bunch of unit tests that you can plug the candidates solution into.
- jswinghammer 16y agoThere are only one or two ways to solve it even remotely efficiently. You can learn both of them.
- EdiX 16y agoThere are only one or two ways if you know what the program is doing, there are many ways to write the one or two solutions in a programming language.
- jswinghammer 16y agoI've asked this question 100-150 times now and I think I've seen everything at this point. The working solutions all look the same or pretty darn close.
- nerfhammer 16y agoYea but there may be an unbounded number of approximation methods that aren't the textbook answer but still diagnostic of competence on behalf of the answerer.
- jswinghammer 16y agoI want a solution to the problem on the terms I defined or they have to give me a pretty good reason why they can't solve it. I usually give tons of hints and let them ask many questions. This never helps those who can't program.
- alextgordon 16y agoReally? There's dozens of permutations for just the function prototype. char* itoa(int value, char* str, int base); char* itoa(int i, void* (*allocator)(size_t)); int itoa(unsigned input, char* buffer, size_t buffer_length); How a non-programmer could recognize the body of the function is beyond me.
- jswinghammer 16y agoWhat's that have to do with anything? In my example the function returns a type of string which doesn't exist in C. The simplest version of the function is one that takes an integer and returns a string. This isn't a trick question and it's not difficult to answer or judge the answer if you take the time to learn it. Assuming that you're going to be hiring a programmer without one handy to help you then you need to read a few books and learn a few things. It's not that hard if you're sufficiently motivated to learn.
- kgo 16y agoIf you, the non-programmer, can learn it, then surely I, the bad programmer, can learn it.
- btilly 16y agoYes, you can. However there are a thousand equivalent questions that you could be asked. Can you memorize them all? How do you find out what they are?
- MiguelHudnandez 16y agoIndeed. At some point, all the preparation and practice is going to turn them into a good programmer!
- jswinghammer 16y agoYou the bad programmer won't. You will get rocked in any such interview because you didn't prepare.
- rubyrescue 16y agoI TOTALLY agree and I've never heard anyone say the same thing. My interviews have all been boiled down to: (a) can they code and TEST int atoi(char *)? (b) Are they a good cultural fit (ie they like the startup environment) (c) Then to be sure, I start giving them some real-world challenges we're having with a product and see if they can help. But (a) eliminates most candidates before I even have to go any further, and if they can do (a) they're generally a good hire. It's kind of bizarre.
- jswinghammer 16y agoAtoi is even easier than itoa :) I hear you. These basic functions make excellent questions.
- chrisaycock 16y agoYeah, I start asking them to code atoi(). That question works miracles.
- cookiecaper 16y agoThe glibc implementation of atoi basically just offloads to strtol, which just offloads to strtol_l.c, which is pretty complex at first glance. You're basically testing to see if people know about casts, right? I'm not a big C developer and most of the languages I spend most of my time in have much less onerous typing systems than C, but if you gave me this question I would probably just write something like: return (int) char; perhaps including a loop to read to the end of char*. Would I pass or not? I don't think I'm that bad of a programmer, just don't have a lot of direct experience with C.
- jswinghammer 16y ago1) In this scenario you are implementing that mechanism. Casts don't work via magic. 2.) C isn't required. The functions use the C conventions for naming. That's all. 3.) That solution would never work because it would return the ASCII value for the character. The solution requires that you go through the string multiplying the value you get by the next power of ten and adding it to what you had before. You work from the 1 position back to the front of the string. You also need to ignore non numerical characters.
- deleted 16y ago[deleted]