[[Perl]] -http://googlewhacks.blogspot.com/2008/02/perl_24.html use Math::Combinatorics; use utf8; binmode(STDOUT, ":utf8"); my @balls = qw(青 赤 黄 緑); print "(1) 4色のボールを順番に並べる\n"; print join("\n", map { join " ", @$_ } permute(@balls)); print "\n"; print "(2) 4色から2色選んで順番に並べる\n"; print join("\n", map { join " ", @$_ } (map { permute (@$_) } combine(2, @balls))); print "\n"; print "(3) 4色から2色選ぶ組合せ\n"; print join("\n", map { join " ", @$_ } combine(2, @balls)); print "\n";