Code (Scala) pasted on 2019-02-01, 00:17 Raw Source
def tetrominos
(amount
: Int, bag
: List
[Char
] = Nil
): List
[Char
] = {
val actualBag
= if (bag.
nonEmpty) bag
else List
('L',
'J',
'S',
'Z',
'T',
'O',
'I')
val index
= Random.
nextInt(actualBag.
size)
actualBag
(index
) :: (amount
match {
case _ => tetrominos
(amount -
1, actualBag.
patch(index, Nil,
1))
})
}
print(tetrominos(50).mkString)