Slaunger wrote:
Hi Gerard,
This definitely looks like a path to walk along, and I think your code
does the trick, although I have to play a little around with the
groupby method, of which I had no prior knowledge. I think I will
write some unit test cases to stress test you concept (on Monday, when
I am back at work).

Yes, it would need plenty of testing - it will not handle the presence of other integers for example. It's a 'quickie' solution of course, but if the data is as regular as you say, then it may be good enough.

I appreciate your almost full implementation - it
would have sufficed to point me to the itertools module, and then I
think I would have figured out.

Apologies. I was in two minds whether to post actual code, but I thought that you could spend a lot of time on a more low-level solution when a 'batteries-included' method would suffice. But, at least you are now aware of itertools - lot's of goodness there, groupby in particular is always my first thought for any kind of data-partitioning problem.

regards

Gerard

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to