Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

detz

macrumors 65816
Original poster
Jun 29, 2007
1,051
0
When I get interviewed I hate the brain teaser and algorithm questions and I want to test his ability to actual program so I would like to give him some simple functions in C, Perl, Php and Python and have him tell me the answers. Anyone have some simple but not to easy functions I could print out and have him solve?
 

lee1210

macrumors 68040
Jan 10, 2005
3,182
3
Dallas, TX
Have him solve for D.

8=D(0)^8

I might not understand the question, but shouldn't D just be:
Code:
double D(int dummy) {
  return pow(8,(1.0/8));
}
Obviously there are some precision issues, but perhaps you meant something more general, like:
Write a function D such that D(X) raised to the power of X evaluates to X.

I may have also misinterpreted the problem. i read that as math, where ^ is exponentiation and = is equivalence. If = were assignment, 8 isn't a modifiable lvalue, so... no matter what D is, that's not compiling... unless...
#define D =
so after the preprocessor you got
Code:
8==(0)^8
which would evaluate to true...

If you meant bitwise XOR, but = is equivalence... then D just needs to return its argument, or always return 0.

Do i get the job? =)

-Lee
 

ChrisA

macrumors G5
Jan 5, 2006
12,922
2,180
Redondo Beach, California
Anyone have some simple but not to easy functions I could print out and have him solve?

What will this person do after you hire him. Will he be asked to write code for well defined "toy" projects like you might have handed to you in school. If so then give him some well defined functions and ask him to write some code. Do you really want to hire a person who can solve "simple but not to easy functions."

But just maybe you want a person who can think about the bigger picture and larger projects. This kind of person is far more valuable, likely older and will cost more. Projects fail not because coders can't write for loops and if statements it is because that is about all they know. You need people who know the subject domain backwards and forwards

During the interview ask questions related to what you want him to do. If that is solving toy problems then ask that. If it is to know how to build larger complex systems ask about how many of those he has built and if he has seen any big systems fail and how to avoid those issues.

Also you are trying to find team players, some one who can work with those you already have and at the same time brings skills you don't already have into the mix.
 

HiRez

macrumors 603
Jan 6, 2004
6,265
2,630
Western US
Um...is it just me or is that ASCII "art" and not really a function at all? Or did I totally miss that Lee was onto it the whole time? :p
 

lee1210

macrumors 68040
Jan 10, 2005
3,182
3
Dallas, TX
I would also say, it would be better to present a realistic situation. If you've closed a bug recently that you consider "simple"... roll the code back to the revision before it was fixed, give them the steps to reproduce the bug, and let them try to fix it. Even if you don't have time to have them work through the whole thing, at least have them walk you through the steps they're taking. Is their first instinct to put in a print statement or fire up a debugger? Can they find the actual executing code, or are they stumbling around in the dark?

-Lee
 

savar

macrumors 68000
Jun 6, 2003
1,950
0
District of Columbia
When I get interviewed I hate the brain teaser and algorithm questions and I want to test his ability to actual program so I would like to give him some simple functions in C, Perl, Php and Python and have him tell me the answers. Anyone have some simple but not to easy functions I could print out and have him solve?

I like to do the following:

1) Ask specific questions about languages and constructs
2) Ask high-level questions about technologies

I have interviewed a few people for a web developer position. For part 1 I ask questions like:

* What is the syntax to pass a variable by reference in PHP?
* What is the syntax for declaring a style for a class in CSS?

These are super-easy questions that the individual should answer correctly without hesitation.

For the second part, I ask general questions that don't necessarily have specific answers, but somebody who has intelligence and experience should be able to discuss the solution:

* What is the difference between HTML and XHTML?
* In MySQL, describe what an index is and a scenario in which you would use one.
* If you were designing an application that requires authentication, how would you store the password credential?

This is all applicable to web programming, but you could come up with similar questions for any language or environment.

Asking to write code an interview is tricky. The thing I like about my approach is that I can quickly understand the extent to which the person has actually grappled with the common problems in our programming domain. If they understand basic syntax as well as high level issues, that indicates to me experience, intelligence, and a genuine desire to be an expert in their field.
 

dbell

macrumors member
Jul 11, 2007
85
0
I might not understand the question, but shouldn't D just be:
Code:
double D(int dummy) {
  return pow(8,(1.0/8));
}
Obviously there are some precision issues, but perhaps you meant something more general, like:
Write a function D such that D(X) raised to the power of X evaluates to X.

I may have also misinterpreted the problem. i read that as math, where ^ is exponentiation and = is equivalence. If = were assignment, 8 isn't a modifiable lvalue, so... no matter what D is, that's not compiling... unless...
#define D =
so after the preprocessor you got
Code:
8==(0)^8
which would evaluate to true...

If you meant bitwise XOR, but = is equivalence... then D just needs to return its argument, or always return 0.

Do i get the job? =)

-Lee

:p You're Hired.

For those wondering... The other acceptable answer is 8=D~(O)^8
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.