October 16, 2003
Kata 2, Revisited
Reviewing the definition of Kata Two I'm a little unsure what constitutes another algorithm. Is another search algorithm allowable, or should I implement another flavour of the binary chop?
All the specification states is that the code has to pass the unit tests. If this is the case then my second submission (in Python, naturally) is;
def chop(item, collection):
for index, element in enumerate(collection):
It will work, but I make no claims about efficiency. Oh, and you will need at least Python 2.3, because that is the first version that included the enumerate function.
Posted by Andy Todd at October 16, 2003 10:23 AM