Link.FYI

Pastebin

Create New My Pastes

Code (Scala) pasted on 2019-02-01, 00:17 Raw Source

  1. import scala.util.Random
  2.  
  3. def tetrominos(amount: Int, bag: List[Char] = Nil): List[Char] = {
  4.   val actualBag = if (bag.nonEmpty) bag else List('L', 'J', 'S', 'Z', 'T', 'O', 'I')
  5.   val index = Random.nextInt(actualBag.size)
  6.   actualBag(index) :: (amount match {
  7.     case 0 => Nil
  8.     case _ => tetrominos(amount - 1, actualBag.patch(index, Nil, 1))
  9.   })
  10. }
  11.  
  12. print(tetrominos(50).mkString)