Skip to content

Instantly share code, notes, and snippets.

@comfly comfly/Summands.hs
Last active Jun 8, 2016

What would you like to do?
All summands combinations
summands 0 = []
summands n = [n]:concat [summandsOfTwo k (n - k) | k <- [1..n `quot` 2]]
where summandsOfTwo l r =
let le = map (r:) (summands l)
re = map (l:) (summands r)
in if l == r then le else le ++ re
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.