DEV Community

loading...

Discussion on: Daily Challenge #299 - Time to Grille!

Collapse
rafaacioly profile image
Rafael Acioly

Scala solution

def grille(text: String, code: Int) = {
  val letters = text.split("")
  val digits = code.toBinaryString.map(_.asDigit)

  val res = letters.toList.reverse.zipAll(digits, 0, 0)

  (res collect { case (i, v) if v != 0 => i }).mkString("")
}
Enter fullscreen mode Exit fullscreen mode