Challenge
Given a list of keys and values, and a target n
, return all sets of keys where the sum of their values equals or exceeds n
.
Input
Input will be like this:
[["Part 1", 20], ["Part 2", 15], ["Part 3", 14.75], ["Part 4", 3]], 30
Input consists of a list with keys (which can be any kind of string) and values (which can be any kind of decimal). Also, a number n
is supplied as the target.
You may take these inputs in any format you like, in any order etc. It needs to support strings, numbers (with decimal precision and possibly negative).
The target might be positive, negative or zero. The list will always contain at least 1 KV-pair.
Each key is guaranteed to be unique. Each value <> 0. Different keys can have the same value. It is not guaranteed that a list holds a satisfactory combination.
Output
The expected output is a list of lists with all keys that have a combined value >=n
. Each set that manages to satisfy this condition needs to be shown in a clearly distinguishable group, for example by separating them with brackets or newlines.
Sample output for the above input:
Part 1, Part2
Part 1, Part 3
Part 1, Part2, Part 3
Part 1, Part2, Part 4
Part 1, Part3, Part 4
Part 1, Part2, Part 3, Part 4
Part2, Part 3, Part 4
Note that each combination needs to be unique. The output doesn't need to be sorted, but part 1, part 2
is considered a duplicate of part 2, part 1
and should not be shown twice.
Additional rules
- Standard loopholes are forbidden
- Answer must be a full program or a function, not a snippet or a REPL-entry.
- code-golf, shortest answer in bytes wins.