Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module Main where
- count :: [Int] -> Int
- count [] = 0
- count (a : xs) = (checkA a xs) + count xs
- checkA :: Int -> [Int] -> Int
- checkA _ [] = 0
- checkA a (b : xs) = (checkB a b xs) + checkA a xs
- checkB :: Int -> Int -> [Int] -> Int
- checkB _ _ [] = 0
- checkB a b (c : xs) = (check a b c) + checkB a b xs
- where
- check a b c = if (a + b > c) && (a + c > b) && (b + c > a) then 1 else 0
- main :: IO ()
- main = do
- print (count l)
- where
- l = [1, 7, 5, 2, 4]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement