You are viewing a single comment's thread. Return to all comments →
Haskell
module Main where import Data.Char (chr, isAlpha, isUpper, ord) rot :: Int -> Char -> Char rot n c | not (isAlpha c) = c | isUpper c = chr $ ord 'A' + (ord c - ord 'A' + n) `mod` 26 | otherwise = chr $ ord 'a' + (ord c - ord 'a' + n) `mod` 26 solve :: Int -> String -> String solve n = map (rot n) main :: IO () main = do _ <- getLine s <- getLine n <- readLn :: IO Int putStrLn $ solve n s
Seems like cookies are disabled on this browser, please enable them to open this website
Caesar Cipher
You are viewing a single comment's thread. Return to all comments →
Haskell