英文字母 26 個字,然後最長三個字串,怎麼讓它排列出所有的組合方式
use strict; use Data::Dumper; use Algorithm::Combinatorics qw(:all); my @data = ('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'); my $k = 3; print Dumper tuples_with_repetition(\@data, $k);
結果,就有 17576 種
$VAR1 = [ 'a', 'a', 'a' ]; $VAR2 = [ 'a', 'a', 'b' ]; (中間省略) $VAR17575 = [ 'z', 'z', 'y' ]; $VAR17576 = [ 'z', 'z', 'z' ];
留言