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!