I used this problem to try out the idea of using test-drive development for writing competitive programming solutions. If you're interested, or just want more information on solving this problem, I wrote up my results here: http://www.redgreencode.com/solving-uva ... nit-tests/