• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: A puzzle
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: A puzzle


  • Subject: Re: A puzzle
  • From: "Mark J. Reed" <email@hidden>
  • Date: Fri, 21 Nov 2008 12:42:33 -0500

On Fri, Nov 21, 2008 at 12:17 PM, Luther Fuller <email@hidden> wrote:
>        set AppleScript's text item delimiters to {"1"}

Clever.  That idea speeds up the Perl version quite a bit, too.  My
original takes about 6 seconds to run:

$ time perl -le 'for (0..999999) { $total += grep { $_ == 1 }
split(//); }; print $total'
600000

real    0m5.844s
user    0m5.841s
sys     0m0.002s


But incorporating your idea takes it down under 1.5:

$ time perl -le 'for (0..999999) { $total += split(/1/,$_.0)-1 }; print $total'
600000

real    0m1.405s
user    0m1.403s
sys     0m0.002s

--
Mark J. Reed <email@hidden>
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: A puzzle
      • From: Skeeve <email@hidden>
References: 
 >A puzzle (From: Michelle Steiner <email@hidden>)
 >Re: A puzzle (From: Luther Fuller <email@hidden>)

  • Prev by Date: Re: A puzzle
  • Next by Date: Re: A puzzle
  • Previous by thread: Re: A puzzle
  • Next by thread: Re: A puzzle
  • Index(es):
    • Date
    • Thread