Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Pin code

by johngg (Canon)
on Sep 12, 2018 at 15:11 UTC ( [id://1222223]=note: print w/replies, xml ) Need Help??


in reply to Pin code

You could use glob to generate the numbers and grep to filter out repeats.

johngg@shiraz:~/perl/Monks$ perl -Mstrict -Mwarnings -E ' my @notOnes = ( 0, 2 .. 9 ); my $globStr = ( q|{| . join( q{,}, @notOnes ) . q|}| ) x 3 . q{1}; say for grep { ! m{(.).*\1} } glob $globStr;' | wc -l 504

I hope this is helpful.

Update: Adding a line to show what the string passed to glob looks like.

johngg@shiraz:~/perl/Monks$ perl -Mstrict -Mwarnings -E ' my @notOnes = ( 0, 2 .. 9 ); my $globStr = ( q|{| . join( q{,}, @notOnes ) . q|}| ) x 3 . q{1}; warn qq{$globStr\n}; say for grep { ! m{(.).*\1} } glob $globStr;' | wc -l {0,2,3,4,5,6,7,8,9}{0,2,3,4,5,6,7,8,9}{0,2,3,4,5,6,7,8,9}1 504

Cheers,

JohnGG

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (2)
As of 2024-04-16 21:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found