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

Re: Golf for unique digits

by davido (Archbishop)
on Jan 10, 2013 at 09:34 UTC ( #1012630=note: print w/replies, xml ) Need Help??


in reply to Golf for unique digits

Hmm, this doesn't beat tye's, but matches it, with a different technique. I wish I could find a way to shave a stroke using this method, but I think I've reached the dead end.

perl -lnE'@h{/./g}--;say~~keys%h'

And this adaptation of tye's shaves a stroke:

perl -lnE'say~~s/(.)(?!.*\1)//g'

Dave

Replies are listed 'Best First'.
Re^2: Golf for unique digits
by BrowserUk (Pope) on Jan 10, 2013 at 09:58 UTC

    This saves 2 strokes over yours:

    perl -plE"@h{/./g}++;$_=keys%h"

    And this saves 2 more over your version of tye's:

    perl -lpE'$_=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://1012630]
help
Chatterbox?
[marto]: so I have to work Saturday, which is good and bad. Bad in the sense that I have to be hear early :( Good in that I am here only as support for another client project, so I get to spend the day working on my personal 'ToDo' list, without the kids :P
[Corion]: marto: Ooof - but yes, being there as only second level support or third level support is good and if you have enough things that you can work on, it won't be a wasted (if paid) day
[marto]: I've opted for a day off later on, rather than pay. I only have to do about 45 mins work for the client, but do need to hang around

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (7)
As of 2017-02-28 10:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?






    Results (399 votes). Check out past polls.