Last active
March 15, 2016 12:42
-
-
Save ngsw-taro/2914c00ec02b3d9a9830 to your computer and use it in GitHub Desktop.
ズンドコ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 実行結果例: | |
* ドコズンズンズンズンズンズンドコズンドコドコドコズンドコズンズンズンドコズンズンズンズンドコキ・ヨ・シ! | |
* ドコズンドコズンドコズンドコドコドコドコ┗(^o^)┛wwwwww┏(^o^)┓ドコドコドコドコwwwwwww | |
*/ | |
fun キヨシ() { | |
val random = Random() | |
fun next() = if (random.nextBoolean()) "ズン" else "ドコ" | |
tailrec fun go(zunOrDoko: String, zunCount: Int, dokoCount: Int) { | |
print(zunOrDoko) | |
val isDoko = zunOrDoko == "ドコ" | |
when { | |
isDoko && dokoCount == 3 -> println("┗(^o^)┛wwwwww┏(^o^)┓ドコドコドコドコwwwwwww") | |
isDoko && zunCount == 4 -> println("キ・ヨ・シ!") | |
else -> go(next(), if (isDoko) 0 else zunCount + 1, if (isDoko) dokoCount + 1 else 0) | |
} | |
} | |
go(next(), 0, 0) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 実行結果例: | |
* ドコズンズンズンズンズンズンドコズンドコドコドコズンドコズンズンズンドコズンズンズンズンドコキ・ヨ・シ! | |
* ドコズンドコズンドコズンドコドコドコドコ┗(^o^)┛wwwwww┏(^o^)┓ドコドコドコドコwwwwwww | |
* ドンドコドンドコ└( ^o^)┐ドンドコ└( ^o^)┐ドンドコドン┌(^o^ )┘ドドンガドン└(^o^)┘ウォォォォーー┌(^o^)┐--ッ 三└(┐卍^o^)卍ドゥルスタッ┌(┌ ^o^)┐ | |
*/ | |
fun キヨシ() { | |
val random = Random() | |
tailrec fun go(zdd: String, zunCount: Int, dokoCount: Int, donCount: Int) { | |
print(zdd) | |
val isDoko = zdd == "ドコ" | |
when { | |
isDoko && dokoCount == 3 -> println("┗(^o^)┛wwwwww┏(^o^)┓ドコドコドコドコwwwwwww") | |
isDoko && zunCount == 4 -> println("キ・ヨ・シ!") | |
isDoko && donCount == 1 -> println("ドンドコ└( ^o^)┐ドンドコ└( ^o^)┐ドンドコドン┌(^o^ )┘ドドンガドン└(^o^)┘ウォォォォーー┌(^o^)┐--ッ 三└(┐卍^o^)卍ドゥルスタッ┌(┌ ^o^)┐") | |
else -> go(random.nextズンドコドン(), | |
if (zdd == "ズン") zunCount + 1 else 0, | |
if (isDoko) dokoCount + 1 else 0, | |
if (zdd == "ドン") donCount + 1 else 0) | |
} | |
} | |
go(random.nextズンドコドン(), 0, 0, 0) | |
} | |
fun Random.nextズンドコドン(): String { | |
val d = nextDouble() | |
return when { | |
d < 0.5 -> "ズン" | |
d < 0.7 -> "ドコ" | |
else -> "ドン" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment