Perl/組み合わせ
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
単語検索
|
最終更新
|
ヘルプ
]
開始行:
[[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";
終了行:
[[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";
ページ名: