4
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

JS ズンドコ コードゴルフ

Last updated at Posted at 2024-01-14

数年前に散々こすられたズンドコキヨシプログラムをJSでコードゴルフしていく。

なお今回は改行文字はカウントしない流派だよ。

81文字
t=''
for(c=1;c;)
t+=Math.random()<.5?(c++,'ズン'):(c=c<5,'ドコ')
console.log(t+'キ・ヨ・シ!')

その他(没)

86文字
for(t='';!t.includes`ズンズンズンズンドコ`;)t+=Math.random()<.5?'ズン':'ドコ'
console.log(t+'キ・ヨ・シ!')
86文字
t=''
while(!t.includes`ズンズンズンズンドコ`)
t+=Math.random()<.5?'ズン':'ドコ'
console.log(t+'キ・ヨ・シ!')
91文字
a='ズン'
b='ドコ'
for(t='';!t.includes(a+a+a+a+b);)t+=Math.random()<.5?a:b
console.log(t+'キ・ヨ・シ!')

改行をカウントする流派の場合

83文字
for(t='',c=1;c;t+=Math.random()<.5?(c++,'ズン'):(c=c<5,'ドコ'));console.log(t+'キ・ヨ・シ!')

コメ欄にて、さらに短い方法があります。

4
2
4

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
4
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?