Skip to content

Instantly share code, notes, and snippets.

@meetlai
Created April 3, 2013 05:07
Show Gist options
  • Save meetlai/5298578 to your computer and use it in GitHub Desktop.
Save meetlai/5298578 to your computer and use it in GitHub Desktop.
import Data.List
import Control.Monad
valid xs = any ((== max) . sum) $ filterM (const [True, False]) left where
max = maximum xs
left = delete max xs
main = do
print $ valid [4, 6, 23, 10, 1, 3]
print $ valid [5, 7, 16, 1, 2]
print $ valid [1, 22, 23, 24, 27, 29, 33]
print $ valid [1, 22, 23, 25, 26]
print $ valid [3, 5, -1, 8, 1, -2, 12]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment