Skip to content

Instantly share code, notes, and snippets.

@masahitojp
Created April 12, 2016 07:47
Show Gist options
  • Select an option

  • Save masahitojp/ba086840c3544c76bcbbcc71fdfecdac to your computer and use it in GitHub Desktop.

Select an option

Save masahitojp/ba086840c3544c76bcbbcc71fdfecdac to your computer and use it in GitHub Desktop.
import scala.annotation.tailrec
import scala.util.Random
object ZDK {
val Z = "Z"
val D = "D"
val K = "K"
@tailrec
def zundoko(zd: List[String] = Nil): List[String] = zd match {
case D :: Z :: Z :: Z :: Z :: _ => zd.reverse
case _ => zundoko((if(Random.nextBoolean) Z else D) :: zd)
}
println(zundoko().mkString("") +K)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment