Thursday, September 01, 2011

annoying interview questions

I do not know the value of what I call "riddle-of-the-spinx" technical job interviews.  Back in the day it was, "show me how you would write a double-linked listed" but who the heck writes double-linked list now a days?

I am not really looking for a new job right now.  I like the job I have, but I thought should go out on some job interviews just to practice.  An interviewer asked me to write, in pseudo code, and program that would output the "Fibonacci numbers" ... you know 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144.  I told the interview I can do that but it will take me some time and I didn't feel like wasting time that way and I really don't like having to code that in a clutch situation, like a job interview.

So I went home and it took me about 10 minutes and I came up with a shell script ...

red@cricket:~$ ./fib.sh
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144
red@cricket:~$ cat fib.sh
#!/bin/sh

first=0
second=1
echo -n "$first, $second, "
thrid=`expr $first + $second`
echo -n $thrid
while [ $thrid -lt 100 ]
do
        first=$second
        second=$thrid
        thrid=`expr $first + $second`
        echo -n ", $thrid"
done
echo ""

... so really what did the interviewer learn from asking me that question?  That I do not like to write code on a white board that cannot execute my code?  That white boards are not good for testing code?
who knows.

No comments:

Post a Comment