Skip to content

Instantly share code, notes, and snippets.

@nipotan
Created December 22, 2015 04:58
Show Gist options
  • Save nipotan/1dd72de01bebb01f9f08 to your computer and use it in GitHub Desktop.
Save nipotan/1dd72de01bebb01f9f08 to your computer and use it in GitHub Desktop.
「Luce」「Twinkle」「Wink」「☆」をランダムに表示し、「Luce Twinkle Wink☆」が完成したら Set Up して終了するプログラム
#!/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