1

Lets say I have 4 balls and when each ball is drawn it can be any value between 1-40 inclusive.

If order isn't important then it would just be $40\cdot 39\cdot 38\cdot 37/4!$

But what if ball 1 had to be between 2 and 9, ball 2 between 9 and 20 and ball 4 had to be between 35 and 40

How would I go about calculating this?

Would it be $8 \cdot 11 \cdot 39 \cdot 5 / 4! $?

azimut
  • 22,696
Gab
  • 53
  • 1
    It's somewhat unclear to me how the second situation you're describing goes. Is it the case that there is one bag with $40$ balls we consecutively pick $4$ and every single one gets removed after it has been picked? And then you assume that the values of the balls are between the above constraints and you're interested in how many ways can this happen? Also when you say "between" do you mean strictly between (i.e. the value of the first ball can be from $3$ up to $8$) or can it include $2$ and $9$? – Timotej Nov 11 '13 at 21:52
  • Yes, this is exactly what I mean. Balls are not replaced. Just removed. And the constraints would be inclusive yes. 1-9 = 1,2,3,4,5,6,7,8,9...etc

    Im just interested in how id figure out how many combos i have with a given set of rules being that its not as simple as 40 x 39 x 38 ... but that each number must be in a specified range.

    – Gab Nov 11 '13 at 22:17

3 Answers3

1

Since the constraints are inclusive the problem is somewhat harder.

The answer is $ 7 \cdot 12 \cdot 6 \cdot 5 + 7 \cdot 12 \cdot 32 \cdot 6 + 11 \cdot 6 \cdot 5 + 11 \cdot 32 \cdot 6$.

We partition the possibilities based on

  1. Whether the first number is $9$ or between $2..8$

  2. Whether the third number is between $35..40$ or not.

The first term counts the number of ways when the first number is between $1..8$ and the third number is in $35..40$ the other terms account for the remaining $3$ cases.

Timotej
  • 1,826
  • Hmm I might need further breaking down. The numbers aren't too important because Ill have to use other numbers eventually. But I'm not quite understanding how you got the equation above

    For example I don't understand why, for the first partition the 4th ball gets multiplied by 5, but the other two partitions by 6.

    – Gab Nov 11 '13 at 22:42
  • So imagine that you drew the first three balls and they were 1 10 and 40. In how many ways can this sequence be finished according to the rules? 5 because it can end in 35,36,37,38,39 but not 40 since it has already been taken out of the bag. On the other hand if the sequence was 1 10 30 then there are 6 possible choices for finishing it off. – Timotej Nov 11 '13 at 23:29
0

Could a mathematician please generalize the solution to the following question: r1min <= b1 <= r1max, r2min <= b2 <= r2max, ... rNmin <= bX <= rNmax, b1 <b2 <... <bX. How to determine the number of solutions (combinations of x balls b with n specified different ranges r), is there pseudocode or programs for it?

0

We can separate this into two cases: a) Ball 1 is not 9 and b) Ball 1 is 9:

In the 1st case, we have 7 choices for Ball 1, 12 choices for Ball 2, 6 choices for Ball 4, and 37 choices for Ball 3, giving $7\cdot12\cdot37\cdot6$ possibilities.

In the 2nd case, we have 1 choice for Ball 1, 11 choices for Ball 2, 6 choices for Ball 4, and 37 choices for Ball 3, giving $1\cdot11\cdot37\cdot6$ possibilities.

Therefore there are $7\cdot12\cdot37\cdot6+1\cdot11\cdot37\cdot6=21,090$ possibilities.

(NOTE: I am assuming that Ball 1 cannot be 1, as stated in the problem.)

user84413
  • 27,211