I attended the Brighton CodingDojo Meet 5 last night where Dan, Richard and Dominic did some binary chopping.
Now, mathematically algorithms are 100 miles away from what I normally do, so I was a little scared about this one. As usual, the session through up a number of discussions about the essence of software development….which to me, is the purpose of the CodingDojo….plus the fact that I enjoy musing about stuff.
I quickly discovered that algorithms weren't particularly suited to rapid, agile development. The code created was pretty rubbish and I certainly wouldn't want to use any of them in real life. The approach seemed to produce long, unreliable code, but now that I think back maybe we just didn't break the task down into smaller sections properly. If so, then it's not Agile's fault, we were just jumping in and trying to code the whole thing in one go.
The shortest and most reliable implementation was from the Java API: Arrays.binarySearch. If there is no good reason to go writing your own implementation then stick with the standard one, it has been tested in thousands in cases and is much less likely to contain an error than your code!
The first three implementations were fairly standard, but when it came to the 4th and 5th then I had an opportunity to be creative. Seems like you need a combination of Developers with maths skills and some with creative skills in order to have a full team.