DEV Community

loading...

Discussion on: Daily Challenge #272 - Printer Errors

Collapse
pavi2410 profile image
Pavitra Golchha • Edited

Kotlin

fun printer_error(input: String): String
    = "${input.filter { it !in 'a'..'m'}.length}/${input.length}"

Output

  • printer_error("aaabbbbhaijjjm") -> 0/14
  • printer_error("aaaxbbbbyyhwawiwjjjwwm") -> 8/22
  • printer_error("aaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbmmmmmmmmmmmmmmmmmmmxyz") -> 3/56
  • printer_error("aaabbbbbbccccccddddddeee") -> 0/24
  • printer_error("verylargepiggoesoink") -> 9/20