Python developer programming tests

December 21st, 2009

I recently administered a programming test to a number of applicants for a Python developer job at 2degreesnetwork.com. Since we now have a new developer (hi Gustavo!), I figured I would post the test and see what kind of response I get to them.

There are two parts to the test, neither are hugely difficult, but there is enough scope in the solutions to understand how the candidate approaches a problem.

In the first part of the test I asked the candidate to look at the following code and implement the thousands_with_commas function, which should take an integer and return a string representation of that integer with commas separating groups of three digits:

def thousands_with_commas(i):

    return str(i)


if __name__ == '__main__':

    assert thousands_with_commas(1234) == '1,234'
    assert thousands_with_commas(123456789) == '123,456,789'
    assert thousands_with_commas(12) == '12'

I think there is a way of doing this with the standard library, and there is also an implementation in Django, but I was looking for a solution from scratch.

It worked quite well as an interview problem, because there is no one obvious solution and there are a few potential gotchas to tackle.

In the second part of the test, I asked the candidate to implement a function that uses a word list to return the anagrams of a given word.

I started them off with the following code:

def annograms(word):

    words = [w.rstrip() for w in open('WORD.LST')]

    raise NotImplementedError


if __name__ == "__main__":

    print annograms("train")
    print '--'
    print annograms('drive')
    print '--'
    print annograms('python')

This part of the test gave a good indication of how much a candidate new about data structures and performance.

You can post code in the comments [code python] like this [/code].

Feel free to post your solutions in the comments, although I suspect I've seen pretty much all variations on possible solutions!

 

Django Desktop

December 20th, 2009

I implemented a theme system for locidesktop.com and thought it only fitting that the first theme I made was one for Django.

I present you with the Django themed Loci Desktop!

Here it is, in embedded form – although you really need to click the above link to fully appreciate it.

 

Javascript Snippets

December 5th, 2009

Since I've been hacking away with Javascript lately, I thought I'd share a few snippets that I have found invaluable.

Some of these snippets use JQuery, but could easily be modified to use plain JS or another toolkit.

Some of these snippets are likely available in other libraries and plugins, but I prefer not to introduce too many dependencies when working with Javascript. Better to keep the code lean – if possible!

 

When did I become the Javascript guy?

December 3rd, 2009

I have been busy working on locidesktop.com lately. One popular feature request from the beta testing was to use website favicons, so that links become more readily identifiable – which I have implemented after several late nights, and abusing my quad core.

3D Favicons example

A few of the 3D Favicons used in locidesktop.com

I built a pipeline that downloads favicons, extracts PNGs which are then processed in to a 3D scene and rendered for missing resolutions (.ICO files can contain multiple resolutions). I've tweaked the way that the 3D icons are produced, and they are significantly better than my first attempt – although some do come out better than others.

The 3D icons are integrated in to locidesktop so that they are pulled in whenever you add a site to your desktop. At the moment I have about 20,000 of them, and I'll be adding more in the future.

The desktop editing interface has been polished considerably, and I think that it is pretty slick now, although there are still plenty of improvements to be made, especially in the area of context sensitive help.

If you really want a beta invite, let me know.

I've also created a test account so that I can demo the features of locidesktop.com without a login. The url is http://locidesktop.com/test/ to view the test desktop, and http://locidesktop.com/test/default/edit/ to play with desktop editing (but you won't be able to save).

As always, I welcome feedback…

 
Search for Posts
2013
 
2012
 
2011
 
2010
 
2009
 
2008
 
2007
 
2006
 
 
© 2008 Will McGugan.

A technoblog blog, design by Will McGugan