Haskell Triangle
import Data.List (sort)
triangle :: [Int] -> Int
triangle a
| length s < 3 = 0
| any valid (zip3 s (drop 1 s) (drop 2 s)) = 1
| otherwise = 0
where
s = sort a
valid (x, y, z) = x > 0 && x > (z - y)
This sorts the values and checks nearby triples, because a valid triangle only needs one local match after sorting.