# Algorithm challenge: the Partition Problem

**URL:** <https://forum.elixirforum.com/t/algorithm-challenge-the-partition-problem/36939>\
**Category:** Discussions\
**Tags:** algorithm\
**Created:** [January 18, 2021, 6:38pm UTC](https://forum.elixirforum.com/t/algorithm-challenge-the-partition-problem/36939 "2021-01-18T18:38:36Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![lud](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/lud/32/14382_2.png) [@lud](https://forum.elixirforum.com/u/lud)\
**Post date:** [February 7, 2022, 10:29am UTC](https://forum.elixirforum.com/t/algorithm-challenge-the-partition-problem/36939/5 "2022-02-07T10:29:01Z")

</div>

> [@dimitarvp](#):
>
> Do you think it’s wrong to assert on the specific pieces of the list in the tests?

It depends on how much you want balanced partitions.

If you only expect partitions to be as evenly sized as possible, then ~~no~~ yes it’s wrong. But if you add in the requirements that the average item size in each partition should also be balanced then ~~yes~~ no it’s not wrong, it could be interesting to expect some sizes.

For instance `{[2,2], [1,1,1,1]}` are “sum-balanced”, but if we consider the average then the right answer should be `{[2,1,1], [2,1,1]}`. And even there, the test should take the list items, and sort them before comparison with the expected answer. Because some algorithms may return `{[2,1,1], [1,2,1]}` which is still valid.

---

_[View the full topic](https://forum.elixirforum.com/t/algorithm-challenge-the-partition-problem/36939)._
