Tuesday, February 20, 2007

PDFTron Interview

I had an interview for a summer internship position with a local software company called PDFTron this morning. I think the interview went pretty well. There were some typical questions asking about my experience and job expectations, as well as some more technical questions involving programming concepts. They also gave me four programming tasks which I had to implement using C++ (writing out code on a piece of paper):

1) Write a function which converts a string to a positive integer. Ignore the '+' and '-' characters, return 0 if the string is empty, and return any interpreted digits if a non-numerical character is encountered. Here was my solution:

int atoi (char * string)
{
if (*string=='\0') return 0;
int value = 0;
while (*string!='\0')
{
if (*string=='0') value+=0;
else if (*string=='1') value++;
else if (*string=='2') value+=2;
else if (*string=='3') value+=3;
else if (*string=='4') value+=4;
else if (*string=='5') value+=5;
else if (*string=='6') value+=6;
else if (*string=='7') value+=7;
else if (*string=='8') value+=8;
else if (*string=='9') value+=9;
else if (*string=='+') value/=10;
else if (*string=='-') value/=10;
else return value/10;
value*=10;
string++;
}
return value/=10;
}

2) Swap positions of the nibbles in a byte:

char nibbleSwap (char byte)
{
char nibble1 = byte&0xF0;
char nibble2 = byte&0x0F;
return ((nibble1/16)|(nibble2*16));
}

3) Write a function which computes x to the power of n using O(log n) multiplications.

int power (int base, int n)
{
if (n == 0) return 1;
if (n == 1) return base;
int half = n/2;
int value = power(base, half);
if (n%2==0) return (value*value);
else return (value*value*base);
}

This has a recurrence relation of T(n) = T(⌊n/2⌋) + Θ(1) for n>=2 and T(n) = Θ(1) for n<2. T(n) is ∈ Θ(log n).

4) Implement a function which draws a line, given coordinates for a start point, coordinates for an end point, and a two dimensional array representing grayscale pixels (8 bits per pixel). I didn't get around to attempting this question since I ran out of time.

Tuesday, February 06, 2007

PlayStation Emulation


I recently installed custom firmware version 3.03 OE-A on my PSP (thanks Dark_AleX!). This allows nearly flawless PlayStation emulation without having to use the official PlayStation Network service for the PS3. I have been spending way too much time replaying FFVII instead of studying for my impending midterms...

Saturday, February 03, 2007

Robotics Conference


I spent the last two days attending the "Robotics for Society: New Directions in Cognitive Science" conference. It took place at Robson Square (downtown Vancouver). Invited speakers included:

James Little (UBC): Space for interaction with a robot
Gordon Cheng (ATR): Humanoid robotics perspective to neuroscience
Richard Vaughan (SFU): Assault and batteries: on the utility of robot aggression, competition and violence
Rodney Brooks (MIT): Robotics and everyday life
Alan Mackworth (UBC): You, robot, do no harm!
Hideki Kozima (NICT): A social robot in the wild world; practices in therapeutic and pedagogical applications
Stefan Schaal (USC): Computational motor control, humanoid robotics, and their societal relevance
Masaaki Honda (Waseda): Talking robot mimicking human speech production
Richard Rosenberg (UBC)

There were also various poster presentations outside of the theater. I found the conference very enjoyable because it provided exposure to a large variety of robots currently being researched and developed. My favorite presentation was by Rodney Brooks. Not only was he an excellent speaker, but he is also very well known in the field of robotics (I read a book by him in high school, as well as some of his research papers). He also founded the iRobot Corporation (well known for the Roomba robots). Unfortunately, attending the conference has put me way behind on my homework, so I am going to be spending the next 24 hours trying to catch up :(.

Dilbert