Recently we called a Code Jam in which the aim was to give people the opportunity to practice Pair Programming and Test Driven Development. The event also gave people the opportunity to share ideas about how to solve the problem. Most people solved the problem in Java or .NET though one pair solved it using Lua.
We chose Prag Daves Anagram Code Kata as the problem to solve. This code kata which involves identifying anagrams in a given list of words is simple enough to solve in a short period of time while offering some interesting challenges from an algorithm point of view.
I have uploaded a solution to the problem in Java. The solution I came up with was entirely Test Driven except for the Main class. I chose to go for an Object Oriented approach as opposed to a small, potentially terse, solution. If you inspect the code you will see it is quite easy to perform arbitrary queries on the anagrams (via the Anagrams.operate method). It should be a simple exercise to create a class that will find the largest set of anagrams or find any other piece of interesting information.
In attempting this problem, the solution I arrived at found 2531 anagrams – Dave Thomas claims there are only 2530. I’m sure there is a further check I could add but I just can’t see what it is at this point. If I ever stumble on it I’ll be sure to make an update to the code and upload it here.
My solution can be found here.
The solution contains the bare minimum, I have not included a build script, nor have I included any binaries. I decided not to include project files either as people were using different IDE’s for their development.
On an unrelated side note, we will call another meeting just as soon as we’ve found a new venue. The venue we were using for our meetings has unfortunately closed. If you know of somewhere near Central that would be suitable please let me know.