DEV Community

Discussion on: Daily Challenge #179 - Hide Phone Numbers

Collapse
 
cipharius profile image
Valts Liepiņš

Haskell, similar idea to my solution in Ruby

import Data.Char (isDigit)

encryptNum :: String -> String
encryptNum = reverse . encryptDigit 0 . reverse
    where
        encryptDigit 6 xs     = xs
        encryptDigit i (x:xs) | isDigit x = 'X' : encryptDigit (i+1) xs
                              | otherwise =  x  : encryptDigit i xs