Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^3: Determining uniqueness in a string.

by Anonymous Monk
on Oct 01, 2005 at 01:53 UTC ( [id://496581]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Determining uniqueness in a string.
in thread Determining uniqueness in a string.

Thanks for the benchmark numbers... I plugged each into my program and the speed improvement was pretty impressive. Now I will spend a while understanding what those code fragments do. :)
  • Comment on Re^3: Determining uniqueness in a string.

Replies are listed 'Best First'.
Re^4: Determining uniqueness in a string.
by thundergnat (Deacon) on Oct 01, 2005 at 02:01 UTC

    Actually, the print statement is probably much more expensive than any of those comparisons.

    Anyway, I noodled with the script a bit.

    #!/usr/bin/perl use warnings; use strict; while ( <> ) { chomp; (/^\d{10}$/) ? print uniq($_)+0,"\n" : die "Not 10 digits.\n"; } sub uniq { return $_[0] !~ /(.).*\1/ }
Re^4: Determining uniqueness in a string.
by Yzzyx (Beadle) on Oct 01, 2005 at 02:37 UTC
    Oops, I wasn't logged in... :)

    The total running time for my program has dropped from 77m18s to 24m14s. I will of course keep working on it. Thanks for the help!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://496581]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (2)
As of 2024-04-20 05:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found