Created
December 22, 2015 04:58
-
-
Save nipotan/1dd72de01bebb01f9f08 to your computer and use it in GitHub Desktop.
「Luce」「Twinkle」「Wink」「☆」をランダムに表示し、「Luce Twinkle Wink☆」が完成したら Set Up して終了するプログラム
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use utf8; | |
{ | |
binmode STDOUT, ':utf8'; | |
local $| = 1; | |
my @words = qw(Luce Twinkle Wink ☆); | |
my $goal = 'Luce Twinkle Wink☆'; | |
my $len = 0; | |
my $name = ''; | |
while (1) { | |
my $word = $words[rand @words]; | |
$word = " " . $word if $len && $word ne '☆'; | |
$len += length($word); | |
print $word; | |
if ($word =~ /^\s?(Luce)/) { | |
$name = $1; | |
} | |
elsif (($name .= $word) eq $goal) { | |
last; | |
} | |
} | |
print " Set Up!!\n"; | |
printf "%d 文字で Set Up しました。\n", $len; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment