0
$\begingroup$

I want to have all the distinct absolute sums of x combinations of (-1,1) and y combinations of (-2,2).

Let's say I sum 3 combinations of (-1,1) and 2 combinations of (-2,2)/ Intuitively, the distinct, absolute, results should be 7, 5, 3, 1 : 1+1+1+2+2=7 1+1-1+2+2=5 1-1-1+2+2=3 -1-1-1+2+2=1 I'm having a hard time finding a mathematical representation of this problem, and also an algorithm to best find the distinct results without calculating all the $2^(x+y)$ possible sums.

  • 0
    By absolute sums you wish only the positive (or zero) sums? And do you want the answer to refer to $x,y$ [numbers of $\pm 1, \pm 2$ used to make the distinct sums]?2017-01-18
  • 0
    Yes, this is what I mean by absolute: a $-2$ result would not be considered distinct from a $2$ result. I'm looking for a mathematical representation including $x, y$ out of curiosity, but what I'm really looking for ultimately is a good way to solve this problem.2017-01-18

1 Answers 1

0

Maximum value must be $(x+2y)$ .

Suppose we change one $+1$ to $-1$.
This gives sum of $(x+2y-2)$

When all $+1$ is changed to $-1$, value must be
$(x+2y-2x)=(2y-x)$

Similarly, switching $+2$ to $-2$ makes values such as $(x+2y-4)$ .
Minimum in this case must be to $(x+2y-4y)=(x-2y)$

So, we can generalize now.

Minimum value is $|2y-x|$
Maximum value is $|2y+x|$

All values can be represented as
$(|2y-x|,|2y-x|+2,\cdots,|2y+x|)$

  • 0
    I have a hard time understanding your representation of the problem I must admit. If you start by stating that $(x+2y)$ is $x$ times $\pm 1$ added to $2y$ times $\pm 1$, how do you get to switching $+2$ and $-2$ ?2017-01-18
  • 0
    $x+2y$ is $x$ times $+1$ plus $y$ times $+2$. if you switch $+1$ to $-1$, the total gets reduced by $2$. Similarly if you switch $+2$ to $-2$, the total gets reduced by $4$.2017-01-18