in reply to Re^3: list of four digit lock combinations without repeated digits
in thread list of four digit lock combinations without repeated digits
Very interesting info, thank you. I often wonder about such
efficiency when writing perl but it doesn't usually matter
too much. I do write postfix loops because they're
pretty and one-line friendly (I ❤ print$_ for@_) but
not when they're nested because I tend to forget about them.
If they're really much faster I could use comments to remind
myself. Anyway your version is slightly faster (~0.750) but
the data has whitespace and when using map to remove that
it gets even slower than mine. What's going on?
Profile:
real 0m1.050stime perl -MAlgorithm::Combinatorics=:all -wle' my $i=variations_with_repetition(["a".."z"],$ARGV[0]); my @x; push @x, map {s/ //gr} qq[@$_] while $_=$i->next; print scalar @x' 4
Profile:
perl -d:NYTProf -MAlgorithm::Combinatorics=:all -wle' my $i=variations_with_repetition(["a".."z"],$ARGV[0]); my @x; push @x, map {s/ //gr} qq[@$_] while $_=$i->next; print scalar @x' 4; nytprofhtml --open
STOP REINVENTING WHEELS, START BUILDING SPACE ROCKETS!—CPAN 🐫
In Section
Seekers of Perl Wisdom