pouët.net

Go to bottom

questions for programmers interview

category: code [glöplog]
btw. my answer to question 1. would be something like (given your number wouldn't be 23 but something WAY HIGHER):
Code: 23 / 16 = 1 [7] // MSB 7 / 8 = 0 [7] 7 / 4 = 1 [3] 3 / 2 = 1 [1] 1/ 1 = 1 [0] // LSB

=> 10111 (that's the complicated approach - for numbers as little as 23 not really needed)

Now for turning bin to hex you just look at 4 bits (3 for octal! - ask for octal - that will kill some guys hard :D) each - that's the most simple conversion approach and also works for pretty high binary numbers (maybe you should ask for a 16bit binary to octal conversion!).
Code: 0001 0111

=> 0x17

Ask this as the first question.
Code: //What's the decimal value of foo? int foo = 023;

I guess that's a killer ;)
added on the 2012-06-28 17:26:36 by las las
023 is an octal number, so: 2 * 8 + 3 = 19.
added on the 2012-06-28 17:30:37 by Adok Adok
psenough somebody who has C++ experience will use the right piping direction - not thinking of it at all - he's a liar.
It's like you are asking a test driver to drive forward and he directly goes for the reverse. FAIL.

I still prefer the 1st guy - he doesn't fail on negative values.
added on the 2012-06-28 17:31:58 by las las
Adok: o'rly?
added on the 2012-06-28 17:32:51 by las las
Quote:
I would not give that piece 100% - consider negative values!


las: not to mention that he could stop at n == 1, since 0! == 1! == 1. ;)
added on the 2012-06-28 17:39:14 by tomaes tomaes
Code:([+-]?)


Quote:
my regex is a bit rusty but shouldnt the dash be escaped here?

I don't think so. If there was another character after it (like [+-Z]) it would be treated as a character range, but if it's the first or last character in the group it's treated as a literal '-'.
added on the 2012-06-28 17:39:32 by gasman gasman
ok, he could not, unless n is > 0, always :] lablabla... ;)
added on the 2012-06-28 17:40:17 by tomaes tomaes
tomaes: exactly. ;)
added on the 2012-06-28 17:40:27 by las las
las: i have c++ experience and might not have gotten that right without checking examples or docs to refresh my memory. unless they're also experienced with linux scripting i dont see why anyone would brain print that info. :p but maybe its just me, my eidetic memory never been that good :p
added on the 2012-06-28 17:40:43 by psenough psenough
border cases are hate - btw. the factorial thing overflows for pretty "small" values of n.
That might be a good question for the "what could possibly go wrong" part...
added on the 2012-06-28 17:45:00 by las las
Quite easier than test I have gone through, but ok it was in notepad as you said and shorter time. Regexp would be challenging because I know shit but given that I was allowed to look at the links who knows? File API would be a bit challenging too because I don't know but I would try to guess. I see people screwing on simple hex stuff (I wish they ask me such questions) but there is the difference, one might happen to know this because of low level coding exp and others not regardless the experience in C#, Java, NET, whatever.
added on the 2012-06-28 17:46:14 by Optimus Optimus
I have never used cout, I don't know what correct piping is.
added on the 2012-06-28 17:47:51 by Optimus Optimus
Ok, since we are all about silly test wanking, here's a simple one (in plain ANSI C):

Code: if (0 ^ 1) printf("a"); if (0 ^ -1) printf("b"); if (1 ^ -1) printf("c");


This is simple, but I guess 90% of all comp.sci bachelor guys would get this wrong. :)
added on the 2012-06-28 17:53:36 by tomaes tomaes
Gargaj:
Quote:
"this is a regex defined to validate and specified input String that really matches this regex."
it's captain obvious! hire immediately!
lol, I was laughing so hard I almost fell from my chair :)

las: I agree with you that I should have talked with some of them after the test, especially with those that almost make - it like the last one, I wish I could tell him "hey, make an effort to clean the code...".

las & psenough: regarding piping direction, I don't think it's such a big deal. but in a test, if you're not sure at something like that, why not use printf?

Optimus: I'm no regex expert myself and frankly I hardly use it. The idea in this question is to test the applicant with something new that he/she doesn't know --- testing their learning curves. However, this gets pointless if preliminarily regex knowledge exists. I'm planning to add another question that require "learning" during the test. I was thinking of some assembler code understand or something similar. Ideas?

tomaes: I personally think that 99% would fail your question, I also think that it can accidently filter out guys I'm interested in. As I said, I'm not looking of an expert/system architect. I'm looking for smart guys with 2-3 years of experience and I believe many of them will fail this question.
added on the 2012-06-28 18:24:07 by TLM TLM
TLM: i'm tempted to say brainfuck but i would really recommend having something related with practical applications instead. debugging someone else's code from an unknown API might be more what you're looking for.. like, giving them the docs and a few examples and telling them to debug or implement from scratch or write some test cases for it. you can throw in some obscure hexadecimal, recursion and such stuff in there while you're at it. actually the whole test could be based on that.
added on the 2012-06-28 18:30:06 by psenough psenough
ask them to debug some stuff from http://underhanded.xcott.com/?page_id=2
added on the 2012-06-28 18:31:56 by Gargaj Gargaj
Or write a smashing demo in Malbolge -> http://en.wikipedia.org/wiki/Malbolge :)
added on the 2012-06-28 18:56:54 by 4Tey 4Tey
psenough: The problem with having something practical is that you quickly start to test experience and not for ability. so, I actually like the brainfuck idea,
it toke me about 5min to understand the hello world sample, so I think it is fair to give in a test.

I might ask what the following program does... This is so nasty - I like!
added on the 2012-06-28 18:57:32 by TLM TLM
"programming" is not a job, it's just the means to do your job. a job is "making robust and fast websites" or "make pretty images for a game" or "make an crossbrosser web sound api". you should make questions relevant to the job, not to the tools the candidate will (probsably NOT) use...
added on the 2012-06-28 20:11:23 by iq iq
iq has a point
added on the 2012-06-28 20:22:58 by psenough psenough
strange.. my job is to "do what the boss says, don't ask questions".
added on the 2012-06-28 20:35:49 by trc_wm trc_wm
iq: The company is an software/hardware design-house. Often, the "job" gets defined by the clients. One of the main problems here is the diversity of the problems a developer faces in the day-to-day. Not only that, it is often required to quickly understand the business aspects of the clients.

So the "job" description would be "a developer that will be quick to adjust and learn new technologies, tools and business aspects along the way". That why I'm focusing on abilities and less on experiences.
added on the 2012-06-28 21:19:16 by TLM TLM
well, i guess i was just trying to compensate for all those opinions who are focusing no how good of a low level bit-hacker or C-magician one is supposed to be in order to be a good programmer. if understanding clients, solving problems and being flexible and adaptable to new techs is what you need, the i'd totally NOT test them by making them write a mutithreaded memory pool in paper without errors. i'd aske them, "if you had to solve this problem, which approach (tools, development phases, modules, technologies) would you use?". you can bring them projects from old clients, and see if they hit any reasonable approach. dunno, whatever. i'm just saying, don't judge them by how good they are at writing regular expresions or do the SBB assembler trick to clamp values without conditional branches. i'm just saying that, i guess.
added on the 2012-06-28 23:30:21 by iq iq
@TLM: guess why it's called brainf*ck? Are you sure you want this kind of programmer?
If so you could also give the following (Single Instruction Computer):
Code:The instruction is "substract and jump if negative", and has three operands: A, B, and C. The instruction will load the content at adress A, substract the content of adress B from it, store the result in adress A and if the latter is negative, jump to C. Here's an example: 0: 10 11 6 ;[10]=[10]-[11]=7-4=3, >=0 so continue with 3 3: 0 10 12 ;[ 0]=[ 0]-[10]=3-7=-4, <0 so jump to 12 ... 10: 7 11: 4 ... The byte 255 (the extra one ;) has a special meaning, because when PC=255 the program stops, and it's also used for I/O handling: 255 B C ;outputs [B] on screen and goto C if B<0 A 255 C ;ask user for [A] and goto C if A<0 Assembler syntax goes like this: ;This is a comment, and is finished by LF label: ;Labels *MUST* finish with : 255 A A:3 ;Will print the number at adress A=2, ie 3 A 255 6 ;Asks for a number and put it in A A 255 *+1 ;*+1 stands for current adress+1, ie 8+1=9 * * 255 ;Same as 9 10 255, which quits because [9]-[10]=9-10<0


And ask what the following program does:
Code:PL: D D D:0 D 0 *+1 OD: M M M:0 M D N:2 M N *+4 INC NUL PP SM: M D SM M DEC NAP D DEC OD PP: 255 N DEC:1 NAP: N INC INC:255 INC NUL NUL:PL

added on the 2012-06-29 00:25:31 by baah baah
I think judging programmers by their ability to "crack"/debug code is a good start.

Understanding clients when you (design) code for the moniez is essential, IMHO.

Testing for coding-corner-cases in a job interview is usually not helpful, I think.
(nice obfuscated loop there, Tigrou. made me think for some minutes)

for everyone failing the fizzbuzz test: "rly?" (how could you ??? :D)
added on the 2012-06-29 00:33:55 by xyz xyz

login

Go to top