Me and my sibling want candies. So, our parent brought us $n$ different candies. Both of us agree that the value of the $i$th candy is $c_i$. Now, we want to split the candies among ourselves so that the total value is as equitable as possible. How to come up with a binary assignment per candy, $x_i$ with $x_i=1$ meaning it goes to me and $x_i=0$ to the sibling?
My attempt: we can express this is an optimization problem with objective function being the sum of squares difference between the total values of my candies and the siblings candies:
$$\min_{x} \left(\sum\limits_{i=1}^n (c_ix_i) - \sum\limits_{i=1}^n c_i(1-x_i)\right)^2 $$
$$s.t. \;\;x_i \in \{0,1\}$$
This can be solved with integer programming software's, but it isn't easy to find free software's that solve these kinds of integer programs. Any thing that can be implemented from scratch in an efficient way?
An equivalent way to minimize the absolute difference is to minimize the maximum. That is, minimize $z$ subject to: \begin{align} \sum_i c_i x_i &\le z\\ \sum_i c_i (1 - x_i) &\le z\\ x_i &\in \{0,1\} \end{align}