Okay so user has 10 points that he / she is allowed to distribute between three factors: a, b and c. As such, the user may choose to put 10 in a but none in b or c (or any other combination). I need an efficient sum of some sort, that will differentiate all possible combinations, due to the sum resulting in different values.
Thanks in advance
Tiny maths question.
Sorry, I'm not clear on what you actually want - you want to know how many possible combinations of point allocations there are?
This sounds suspiciously like a school assignment...
Here's one way to look at it. Given the contraint that a+b+c=N, you only have two degrees of freedom. Once you choose a, you have N-a options for b. At that point, c has only one option: N-a-b. So:
a=N: b=0 c=0
a=N-1: b=0 c=1, b=1 c=0
a=N-2: b=0 c=2, b=1 c=1, b=2 c=0
a=N-3: b=0 c=3, b=1 c=2, b=2 c=1, b=3 c=0
...
a=0: b=0 c=N, b=1 c=N-1, b=2 c=N-2, b=3 c=N-3, ..., b=N c=0
If you visualize the pattern on an N×N square, the valid combinations form a triangle including the diagonal. That gives N×(N+1)/2 combinations. (If it excluded the diagonal, it would be N×(N-1)/2 instead.)
Here's one way to look at it. Given the contraint that a+b+c=N, you only have two degrees of freedom. Once you choose a, you have N-a options for b. At that point, c has only one option: N-a-b. So:
a=N: b=0 c=0
a=N-1: b=0 c=1, b=1 c=0
a=N-2: b=0 c=2, b=1 c=1, b=2 c=0
a=N-3: b=0 c=3, b=1 c=2, b=2 c=1, b=3 c=0
...
a=0: b=0 c=N, b=1 c=N-1, b=2 c=N-2, b=3 c=N-3, ..., b=N c=0
If you visualize the pattern on an N×N square, the valid combinations form a triangle including the diagonal. That gives N×(N+1)/2 combinations. (If it excluded the diagonal, it would be N×(N-1)/2 instead.)
* . . . . . . . . .
* * . . . . . . . .
* * * . . . . . . .
* * * * . . . . . .
* * * * * . . . . .
* * * * * * . . . .
* * * * * * * . . .
* * * * * * * * . .
* * * * * * * * * .
* * * * * * * * * *
Okay so user has 10 points that he / she is allowed to distribute between three factors: a, b and c. As such, the user may choose to put 10 in a but none in b or c (or any other combination). I need an efficient sum of some sort, that will differentiate all possible combinations, due to the sum resulting in different values.
Thanks in advance
Why not just use 11a + b?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement