Created
March 26, 2016 00:44
-
-
Save dnoguchi/f4a86032be5727d3227d 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
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