wrecking-yard / ex_subset_sum

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ExSubsetSum

based on https://panduwana.wordpress.com/2010/04/21/combination-in-erlang/

Description

See here

Example

iex> ExSubsetSum.sum_of_one(Enum.to_list(1..10), 10)
[
  [10],
  [1, 9],
  [2, 8],
  [3, 7],
  [4, 6],
  [1, 2, 7],
  [1, 3, 6],
  [1, 4, 5],
  [2, 3, 5],
  [1, 2, 3, 4]
]

iex> ExSubsetSum.sum_of_all(Enum.to_list(1..10), [1, 4, 5])
[
  [10],
  [1, 9],
  [2, 8],
  [3, 7],
  [4, 6],
  [1, 2, 7],
  [1, 3, 6],
  [1, 4, 5],
  [2, 3, 5],
  [1, 2, 3, 4]
]

About


Languages

Language:Elixir 100.0%