in reply to Re: simplify the code
in thread simplify the code

The second one looks quite intimidating, IMHO. The first one could be clearer if you chose your temporary variables just a tad better. The code I ended up writing looks is almost identical to your first loop, except for the choice of temporaries; and I think it looks a lot clearer.

Makeshifts last the longest.