-
-
Save goakley/7209d1cda8bfc8b3b73c76fe334c6032 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
input :: [String] | |
input = [ | |
"billowy", | |
"biopsy", | |
"chinos", | |
"defaced", | |
"chintz", | |
"sponged", | |
"bijoux", | |
"abhors", | |
"fiddle", | |
"begins", | |
"chimps", | |
"wronged"] | |
isSorted :: (a -> a -> Bool) -> [a] -> Bool | |
isSorted cmp xs = and $ zipWith cmp xs (tail xs) | |
solve :: String -> String | |
solve xs | |
| isSorted asc xs = xs ++ " IN ORDER" | |
| isSorted desc xs = xs ++ " REVERSE ORDER" | |
| otherwise = xs ++ " NOT IN ORDER" | |
where asc = (<=) | |
desc = (>=) | |
main :: IO () | |
main = mapM_ (putStrLn . solve) input |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment