Monday, July 19, 2004

Computer Science Tech Interviews - Evolution

Yesterday I was discussing CS Technical Interview programming questions and their evolution with a fellow techie. And we came to the interesting problem that says " Write a program in any language that prints itself". Stated more formally here is the problem statement:

Objective
The objective of this assignment is to think a little deeper about the expressiveness of your favorite programming language.

Requirements
For this assignment you are to write a program that when executed prints a copy of itself. This sounds deceptively easy. Your program cannot read in any data. Obviously, writing a program that reads in the source file for the program and prints it is both trivial and not the solution to this problem.

I felt this is a order 15 complexity (on Don Knuth scale) problem. Now this is a problem that can stump even advanced programmers because of the sheer novelty factor it brings. The debate was whether these problems should be used to hire potential software developers.

Here is a small C program that can do it ...
#include >stdio.h>;
char *s="char *s=%c%s%c;%cmain(){printf(s,34,s,34,10,10);}%c";
main(){printf(s,34,s,34,10,10);}

Now the debate is whether these problems over the board test programming skills or analytical or something else. (I think none as any CS UnderGrad given sufficient time can solve this, but here we are talking about testing the potential problem solving skills of the person).
I shall ask you readers to comment on this particular problem and say what you think about the inclusion of this as a hire question.

No comments: