1
$\begingroup$

I'm doing a programming challenge and I'm stuck at this problem. Basically I have to find how many possible integer solutions exist given the following equation:

$x_1 + x_2 + ...+ x_n = m $

And the following constraints:

$1 \le x_1 \lt x_2 < ... \lt x_n $

Let's make an example. I have this equation:

$x_1 + x_2 = 10$

The constraint in this case is:

$x_1 \ge 1$ and $x_2 > x_1 $

I'm sure there's a combinatoric way to find the number of possible solutions of this equation. At first I thoungth that I could calculate all the possible solutions without the stricter constraint (basically saying that all the numbers must be positive numbers) and then find the exact solution by removing all the sequences that do not satisfy the stricter constraint.

Any help is appreciated! Thanks to everyone!

  • 1
    Sounds like you're working on a [Kakuro](https://en.wikipedia.org/wiki/Kakuro) implementation. You need some information on [distinct partitions](https://en.wikipedia.org/wiki/Partition_(number_theory)#Odd_parts_and_distinct_parts). Good luck.2017-02-12

0 Answers 0