Last active
August 3, 2017 10:17
-
-
Save honzabrecka/e225dc3cdb8f2bdae445c7c5fd067385 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
module Problem1 where | |
import Prelude | |
import Data.List | |
isIncreasing :: List Int -> Boolean | |
isIncreasing Nil = true | |
isIncreasing (_ : Nil) = true | |
isIncreasing (x : y : ys) | x < y = isIncreasing (y : ys) | |
| otherwise = false | |
isPossibleIncreasing :: List Int -> Boolean | |
isPossibleIncreasing l = inner 0 l | |
where | |
inner :: Int -> List Int -> Boolean | |
inner _ Nil = true | |
inner _ (_ : Nil) = true | |
inner n (x : y : ys) | x < y = inner x (y : ys) | |
| x > n = isIncreasing(x : ys) | |
| y > n = isIncreasing(y : ys) | |
| otherwise = false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment