LoginSignup
0
0

More than 5 years have passed since last update.

ズンドコキヨシ with Perl

Last updated at Posted at 2016-03-11

Perlでやってみた
※Use of uninitialized valueを出すという初歩的なミスをしていたのでついでに諸々修正しました…

Perl版

kiyoshi.pl
use strict;
use warnings;

sub kiyoshi {
  my @zd  = my ($z, $d) = ('ズン', 'ドコ');
  my $str = join('', (my @kys = ($z, $z, $z, $z, $d)));
  my $cnt = 0;
  my @word;

  while ( join('', @word) ne $str ) {
    shift @word if $#word >= $#kys;
    push @word, $zd[rand(@zd)];
    print $word[$#word];
    $cnt++;
  }
  print "キ・ヨ・シ!\n($cnt回ズンドコしました)\n";
  return;
}

kiyoshi();

もうちょっと上手くできないものか…

0
0
0

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
0
0