LoginSignup
11
10

More than 5 years have passed since last update.

ズンドコキヨシ with JavaScript (Node.js)

Last updated at Posted at 2016-03-12

ズンドコキヨシを、見かけたので、JavaScriptでやってみた。

zundo-kiyoshi.js
// ズンズンズンズンドコキ・ヨ・シ!

void function () {
    'use strict';

    var phrase = 'ズンズンズンズンドコ';

    var puts = typeof process === 'object' && process &&
            typeof process.stdout === 'object' && process.stdout &&
            typeof process.stdout.write === 'function' ?
        process.stdout.write.bind(process.stdout) :
        console.log.bind(console);

    var generated = '';
    do {
        var choise = ['ズン', 'ドコ'][Math.random() * 2 | 0];
        puts(choise);
        generated = (generated + choise).substr(- phrase.length);
    } while (generated !== phrase);
    puts('キ・ヨ・シ!');
}();

久しぶりに do {} while (); とか使ってみた。使う事はほとんど無い。笑

実行例
$ node zundoko-kiyoshi.js
ドコズンズンドコズンズンズンズンズンズンズンズンズンドコキ・ヨ・シ!
$

参考

ズンドコキヨシ with Perl6 - Qiita

ズンドコキヨシまとめ - Qiita

11
10
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
11
10