loading...

Discussion on: Daily Challenge #272 - Printer Errors

Collapse
aminnairi profile image
Amin

Haskell

module Main where


getPrinterErrorRate :: String -> String
getPrinterErrorRate x =
    show (length $ filter (not . flip elem ['a'..'m']) x)
        ++ "/"
        ++ show (length x)


main :: IO ()
main = do
    print $ getPrinterErrorRate "aaabbbbhaijjjm" -- "0/14"
    print $ getPrinterErrorRate "aaaxbbbbyyhwawiwjjjwwm" -- "8/22"
    print $ getPrinterErrorRate "aaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbmmmmmmmmmmmmmmmmmmmxyz" -- 3/56
    print $ getPrinterErrorRate "aaabbbbbbccccccddddddeee" -- "0/24"
    print $ getPrinterErrorRate "verylargepiggoesoink" -- "9/20"

Test