Problems? Is your data what you think it is? | |
PerlMonks |
Re: list of four digit lock combinations without repeated digitsby johngg (Canon) |
on Jun 20, 2018 at 22:06 UTC ( [id://1217078]=note: print w/replies, xml ) | Need Help?? |
A solution using glob to generate the 4-digit numbers, split, sort and join to get only ascending values then grep and a regex to sift out repeating digits. A hash is populated so that any duplicate values go into the same key/value pair and are therefore masked. Finally print the sorted values.
I hope this is of interest. Update: Can be shortened by acting directly on an anonymous hash but there's a warning unless you silence it (which, sadly, makes it not so short again).
Cheers, JohnGG
In Section
Seekers of Perl Wisdom
|
|