4
4

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.

Rでズンドコ

Last updated at Posted at 2016-03-13

こういうのをPythonでも書きたいだけの人生だった

zun.R
(function(a,b){if(b==5){c(a,'キ・ヨ・シ!')}else if(rbinom(1,1,0.5)>0){Recall(c(a,'ズン'),b-1)}else{Recall(c(a,'ドコ'),4+(b<=0)*1)}})('',4)

JavaScriptでも同じようにかけるけど、ちょっと長くなる。

実行結果
Rscript zun.R
 [1] ""             "ズン"         "ズン"         "ズン"         "ドコ"        
 [6] "ドコ"         "ズン"         "ドコ"         "ドコ"         "ズン"        
[11] "ドコ"         "ズン"         "ズン"         "ドコ"         "ドコ"        
[16] "ドコ"         "ズン"         "ドコ"         "ドコ"         "ズン"        
[21] "ドコ"         "ドコ"         "ズン"         "ドコ"         "ドコ"        
[26] "ドコ"         "ズン"         "ドコ"         "ズン"         "ズン"        
[31] "ドコ"         "ドコ"         "ドコ"         "ズン"         "ドコ"        
[36] "ズン"         "ズン"         "ズン"         "ドコ"         "ズン"        
[41] "ドコ"         "ドコ"         "ドコ"         "ドコ"         "ズン"        
[46] "ズン"         "ズン"         "ドコ"         "ドコ"         "ドコ"        
[51] "ドコ"         "ドコ"         "ドコ"         "ドコ"         "ズン"        
[56] "ドコ"         "ドコ"         "ドコ"         "ズン"         "ズン"        
[61] "ズン"         "ズン"         "ズン"         "ズン"         "ズン"        
[66] "ズン"         "ズン"         "ズン"         "ズン"         "ドコ"        
[71] "キ・ヨ・シ!"

妥協したPython版

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?