Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Re^9: Finding repeat sequences.

by hdb (Monsignor)
on Jun 21, 2013 at 18:41 UTC ( #1040209=note: print w/replies, xml ) Need Help??

in reply to Re^8: Finding repeat sequences.
in thread Finding repeat sequences.

Sir, you are correct. I was thinking of a string of 'a's but that one case is already covered by the initial until condition.

Interesting that my last modification timed out. Did you run it with $i or $i+1?

Replies are listed 'Best First'.
Re^10: Finding repeat sequences.
by BrowserUk (Pope) on Jun 21, 2013 at 19:28 UTC
    Interesting that my last modification timed out. Did you run it with $i or $i+1?

    Exactly as you posted it (c&p).

    I just added print "i:$i j:$j"; to the bottom of the loop and it shows what happens:

    i:1 j:1 i:1 j:1 i:1 j:1 i:1 j:1 i:1 j:1 i:1 j:1 i:1 j:1 i:1 j:1 ...

    Your concern about my use of $i+1 ignores the difference in the relative ordering of the ++$i increment in my version and yours. (The original.)

    And your addition of the if statement never avoids the need to perform the index, so is pure overhead.

    As for the possibility of out-by-one errors:

    I'll trade the need to fix them, for the ability to make them; when the alternative is to rely upon the (unseen, unknown, uncontrollable, and possibly non-existent) generic optimisations of a declarative tool to convert a high-level -- and potentially completely broken -- abstract description of my problem into an efficient solution.

    Had I opted for that approach, I would have settled on Damian's original solution. There would have been no incentive for him to improve it; or you to correct and improve yours.

    The result would have been that my application for this; currently running on one of my 4 cores and projected to run for 7 to 10 days; would have projected to run for 143 1110 years! In other words, it would have been abandoned.

    Far too often people settle for the first solution on offer -- cpan -- and never consider the affect their choices have.

    So yes, I'll willingly trade the need to correct out-by-one errors; for the ability to make them in the first place.

    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1040209]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2018-07-19 23:36 GMT
Find Nodes?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?

    Results (421 votes). Check out past polls.