Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^2: Golf for unique digits (17)

by tye (Cardinal)
on Jan 09, 2013 at 18:42 UTC ( #1012541=note: print w/ replies, xml ) Need Help??


in reply to Re: Golf for unique digits
in thread Golf for unique digits

perl -nlE"say 0+s/(.)(?!.*\1)//g"

- tye        


Comment on Re^2: Golf for unique digits (17)
Download Code
Re^3: Golf for unique digits (17)
by BrowserUk (Pope) on Jan 09, 2013 at 18:52 UTC

    tye++ ... but I'm stuck to understand how it works?

    According to perlop:

    Searches a string for a pattern, and if found, replaces that pattern with the replacement text and returns the number of substitutions made.

    How does the number of substitutions made equate to the number of characters left after the substitutions?


    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.
      >How does the number of substitutions made equate to the number of characters left after the substitutions?

      (?!..) = not followed by!

      every cipher is exactly once the last of it's kind! =)

      Cheers Rolf

        Of course! Thanks.


        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.
Re^3: Golf for unique digits (15)
by BrowserUk (Pope) on Jan 09, 2013 at 18:56 UTC

    This seems to work just as well?

    perl -nlE"say s/(.)(?!.*\1)//g"

    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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (8)
As of 2014-09-17 13:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (79 votes), past polls