in reply to Re^6: list of four digit lock combinations without repeated digits
in thread list of four digit lock combinations without repeated digits
push @x, pack "A*", qq[@$_] while $_=$i->next;
That would probably match if not beat join, if you weren't stringifying the array twice.
Ie. Use push @x, pack "(A*)*", @$_ while $_=$i->next;
Of course, if you want to put all the sequences as strings into an array, this is easier and probably quicker;
my @x = map join( '', @$_ ), variations_with_repetition( ["a".."z"], 4 + );; print scalar @x;; 456976
And if all you want to do is print the count, then:
[ 7:10:21.87] C:\test>perl -MAlgorithm::Combinatorics=:all -le"print s +calar( () = variations_with_repetition( ["a".."z"], $ARGV[0] ) )" 4 456976 [ 7:10:27.12] C:\test>
BTW, that is one seriously quick machine you're running. What is it? (6x faster than my (admittedly ancient) box.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^8: list of four digit lock combinations without repeated digits
by usemodperl (Beadle) on Jun 22, 2018 at 23:57 UTC |