Haskell solution, will happily answer questions:
import Data.Maybe (fromMaybe) import Data.List (elemIndex) import Data.Char (digitToInt, intToDigit, toUpper, toLower) solve :: Int -> String -> String solve n = reverse . fmapEvenOdd toUpper toLower . fmap (complement . shift n) fmapEvenOdd :: (a -> b) -> (a -> b) -> [a] -> [b] fmapEvenOdd f g (x:y:xs) = f x:g y:fmapEvenOdd f g xs fmapEvenOdd f _ [x] = [f x] fmapEvenOdd _ _ [] = [] complement :: Char -> Char complement c | isDigit c = intToDigit $ 9 - (digitToInt c) | otherwise = c shift :: Int -> Char -> Char shift n c = fromMaybe c $ fmap ((chars !!) . (`mod` length chars) . (+n)) $ elemIndex c chars where chars = ['A'..'Z']
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Haskell solution, will happily answer questions: