Skip to content

Instantly share code, notes, and snippets.

@karupanerura
Created November 10, 2011 10:46
Show Gist options
  • Save karupanerura/1354587 to your computer and use it in GitHub Desktop.
Save karupanerura/1354587 to your computer and use it in GitHub Desktop.
天使と悪魔問題
use strict;
use warnings;
use 5.10.0;
use utf8;
use open ':encoding(utf-8)';
use open ':std';
use constant {
ANGEL => '天使',
DEVIL => '悪魔',
};
foreach my $a (ANGEL, DEVIL) {
foreach my $b (ANGEL, DEVIL) {
### See also: http://ja.wikipedia.org/wiki/%E8%AB%96%E7%90%86%E5%8C%85%E5%90%AB
my $real_answer = ($a ne ANGEL or $b eq ANGEL);
$real_answer = not $real_answer if $a eq DEVIL;
my $real = $real_answer ? '真' : '偽';
$real .= ': ';
$real .= "$a「私が天使なら彼女($b)も天使です。」";
say $real;
}
}
__END__
真: 天使「私が天使なら彼女(天使)も天使です。」
偽: 天使「私が天使なら彼女(悪魔)も天使です。」
偽: 悪魔「私が天使なら彼女(天使)も天使です。」
偽: 悪魔「私が天使なら彼女(悪魔)も天使です。」
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment