Skip to content

Instantly share code, notes, and snippets.

@siosio
Last active August 29, 2015 14:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save siosio/89030f100e42d9c8e7c7 to your computer and use it in GitHub Desktop.
Save siosio/89030f100e42d9c8e7c7 to your computer and use it in GitHub Desktop.
( ・ㅂ・)و ̑̑ グッ
import java.util.Random
private val INPUT = arrayListOf("ジョ", "ン", "ボ", "ヴィ")
private val RANDOM = Random()
fun main(args: Array<String>) {
var count = 0
val generator: () -> String = {
count++
stream {() -> RANDOM.nextInt(INPUT.size) }
.take(2)
.map { i -> INPUT.get(i) }
.toList()
.join("")
}
val result = stream(generator(), {it + "・" + generator() })
.first{it.endsWith("ジョン・ボン・ジョヴィ")}
println("""
${result}
${count} Bon Jovis
_人人人人人人人人人人人人人人_
> You Give Love a Bad Name <
 ̄Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y ̄
""")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment