On Dec 18, 2007 5:21 PM, Peter Hardy <[EMAIL PROTECTED]> wrote: > On Tue, 2007-12-18 at 16:09 +1100, Jeff Waugh wrote: > > Here's a starting point. What's a more optimal way to perform this task? :-) > > > > sed 's#[^,]*##g' input.txt | tr -d '\n' | wc -m > > > > Tuesday afternoon shell optimisation party! > > How do you want it optimised?
Well, for readability, speed and code size this handy BF program is easily the winner: >,[<++++[->>+++++++++++<<]>>[-<->]+<[[-]>-<]>[->+<]<,]>>. Keep in mind it's also optimised for usability, so the output is the ascii value of the number rather than the number itself. It only handles up to 255 commas (unless you have a unicode BF interpreter.) HTH, Sam -- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html