26 lines
622 B
Markdown
26 lines
622 B
Markdown
# Powerset
|
|
|
|
## What is this exercise about?
|
|
|
|
Imagine you have a bag of numbered balls, and you want to find all the different ways you can pick some balls so that the numbers on them add up to a specific target number.
|
|
|
|
This is exactly what the **powerset** exercise does!
|
|
|
|
## Real-world example
|
|
|
|
Let's say you have these numbered balls: **1, 2, 3, 4, 5**
|
|
|
|
And you want to find all the ways to pick balls that add up to **5**.
|
|
|
|
Here are all the possible ways:
|
|
- Pick just ball **5** → 5 = 5
|
|
- Pick balls **1** and **4** → 1 + 4 = 5
|
|
- Pick balls **2** and **3** → 2 + 3 = 5
|
|
|
|
So the answer would be:
|
|
```
|
|
5
|
|
1 4
|
|
2 3
|
|
```
|