• + 0 comments

    Haskell

    module Main where
    
    import Control.Monad (replicateM_)
    import Data.Char (ord)
    
    cDif :: Char -> Char -> Int
    cDif x y = abs (ord x - ord y)
    
    sDif :: String -> [Int]
    sDif s = zipWith cDif s (tail s)
    
    solve :: String -> String
    solve s
        | sDif s == sDif (reverse s) = "Funny"
        | otherwise = "Not Funny"
    
    main :: IO ()
    main = do
        cases <- readLn :: IO Int
        replicateM_ cases $ do
            s <- getLine :: IO String
            putStrLn $ solve s