Andrew Channels Dexter Pinion

Wherein I write some stuff that you may like to read. Or not, its up to you really.

October 15, 2003

Kata 2, Pass 1

Now I've skipped to Kata 2. My first pass is a fairly standard, procedural, binary search;

def chop(item, collection):

    while ( start <= end ):
        if item==collection[middle]:
            return middle
        elif item < collection[middle]:
            end = middle-1
            start = middle+1
    return -1

For my next exercise I'm going to try either a recursive solution or something with generators. I'm just hoping it will take slightly less than the two hours it took me to come up with this one.

Posted by Andy Todd at October 15, 2003 09:45 PM