4
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Get,GetGetGetWildAndTough! Perl版

Last updated at Posted at 2017-07-21

コード

my $GET = 'Get';
my $WILD = 'Wild';
my $AND = 'and';
my $TOUGH = 'Tough';

my @GetWildAndTough = ($GET, $WILD, $AND, $TOUGH);
my @GetChanceAndLuck = (9, 9, 9);

while (1) {
	my $gwat = int(rand(3));
	print $GetWildAndTough[$gwat] . "\n";
	shift(@GetChanceAndLuck);
	push(@GetChanceAndLuck, $gwat);
	my $dream = 1;
	while(my ($T, $N) = each @GetChanceAndLuck){
		if ($T != $N) {
			$dream = 0;
		}
	}
	last if ($dream);
}
print $GetWildAndTough[3] . "\n";
exit;

出力

Wild
Get
and
Get
and
Get
and
Get
and
Get
Get
Wild
and
Tough

なにこれ?

ひとりでは消せない痛み

仕様

「Get」 「Wild」 「and」 をランダムに出力します。
「Get Wild and」の順に出力されたら「Tough」と出力して終了します。

元ネタ

4
1
3

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?