• + 0 comments

    HASKELL

    rotate :: [Char] -> String 
    rotate [] = []
    rotate (x:xs) = xs ++ [x]
    
    rotateAll :: [Char] -> String
    rotateAll s = unwords $ auxRotate (rotate s) (length s)
        where  
            auxRotate rs 0 = []
            auxRotate rs n = rs : auxRotate (rotate rs) (n-1)
    
    main :: IO ()
    main = interact $ unlines . map rotateAll .  drop 1 . lines