11
10

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.

ズンドコキヨシ 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]
(http://qiita.com/B73W56H84/items/519e27a1aed5e6d5304f)

[ズンドコキヨシまとめ - Qiita]
(http://qiita.com/shunsugai@github/items/971a15461de29563bf90)

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?