Skip to content

Instantly share code, notes, and snippets.

@dnoguchi
Created March 26, 2016 00:44
Show Gist options
  • Save dnoguchi/f4a86032be5727d3227d to your computer and use it in GitHub Desktop.
Save dnoguchi/f4a86032be5727d3227d to your computer and use it in GitHub Desktop.
ズンドコプログラム
object Main {
def main(args: Array[String]) {
kiyoshi( List() )
}
def kiyoshi(list: List[String]): Unit = {
list.reverse match {
case List("ズン", "ズン", "ズン", "ズン", "ドコ") => println("キ・ヨ・シ!"); sys.exit();
case _ => {
val next = shout()
println(next)
kiyoshi(next :: prune(list))
}
}
}
def shout() = {
import scala.util.Random
val r = new Random()
val list = List("ズン", "ドコ")
r.shuffle(list).head
}
def prune(list: List[String]) = list.size match {
case 5 => list.reverse.tail.reverse
case _ => list
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment