tdenkinger's Journal http://use.perl.org/~tdenkinger/journal/ tdenkinger's use Perl Journal en-us use Perl; is Copyright 1998-2006, Chris Nandor. Stories, comments, journals, and other submissions posted on use Perl; are Copyright their respective owners. 2012-01-25T02:48:54+00:00 pudge pudge@perl.org Technology hourly 1 1970-01-01T00:00+00:00 tdenkinger's Journal http://use.perl.org/images/topics/useperl.gif http://use.perl.org/~tdenkinger/journal/ Amazon Interview http://use.perl.org/~tdenkinger/journal/31768?from=rss So, my current employer is making it clear my business unit will soon be dissolved. Apparently advertising-based internet operations are <em> &agrave; la mode</em>, and having actual paying subscribers to a decent service is pass&eacute;. So not too long ago I interviewed at Amazon. After two technical phone interviews, I was brought to Seattle for a day of in-person interviews. <p> Things went generally pretty well, though I didn't get an offer. One of the interview sessions stands out as particularly bad, and I'm sure that had a big impact on their decision. </p><p> The interviewer asked me to write a function that would turn a number into words. The upper bounds for the exercise was 100,000,000,000. So, 1,025 should become "one thousand twenty-five". I was told to use any "first tier" language, "C, C++, Java". He agreed that Perl would be fine too. </p><p> When I look at this exercise, I see a word problem, not a number problem. Divide the number up into three character chunks (with a possible element less than three characters) and turn that into words. It's basically "commify" with a twist. </p><p> So, I set about writing a little code on the whiteboard. First, I reversed the string (the number) and started iterating over it pulling out chunks with a substr(). My goal was to get the three char chunks into an array. I know there are better ways to do this, but under stress I took the route I thought of first. </p><p> I was stopped by the interviewer almost immediately and was asked why I was treating the number as a string. For a moment the question didn't even make sense to me. Had I been thinking clearly and not been confused, I might have asked him why it <em>shouldn't</em> be treated as a string. Mostly I just stammered and blew the rest of the interview. </p><p> The solution he was looking for used "% 1000" to get the chunk followed by "/ 1000" to set the number up for the next call to the modulus. It's possible I would never have gotten to that solution without prodding from the interviewer. </p><p> The whole experience was humbling, but not terrible. I learned a bit about Huffman coding from another interviewer and implementing database-based linked lists from another. </p><p> I also got really good insight into some interviewing techniques that maybe I'll be able to use sometime.</p> tdenkinger 2006-11-30T15:55:24+00:00 journal