# 7 Numbered Balls Game

You are walking on the street and notice a guy gambling with some other guys and you start to watch.

The game principle is pretty easy. There are 7 balls in a pouch and you have 3 balls to draw randomly. If two balls you choose consecutively are consecutive, you win, otherwise the gambler wins.

For example,

• You choose 1,4,3. You win because 4 and 3 are consecutive numbers
• You choose 4,5 consecutively and you win without drawing a third ball since 4 and 5 are already consecutive.
• You choose 1,7,2 in that order. You lose, because there are no consecutive numbers in succession.

Should you play this game or not in the long run?

• I assume it's an "even money" game? ie you're paid odds of 1:1? – Bohemian Aug 29 '16 at 18:39
• Would you still win if you draw 4,3,7 since 3 and 4 are consecutive? even though they're in reverse order? – dcfyj Aug 29 '16 at 18:39
• @dcfyj yes, 4,3 is enough to draw since they are consecutive – Oray Aug 29 '16 at 18:40
• @Bohemian yes 1:1. – Oray Aug 29 '16 at 18:40

Let $A$ be the event that the first two balls are consecutive, and $B$ be the event the second two are. Your probability of winning is $P(A\text{ or }B)$, which is the same as $P(A)+P(B)-P(A\text{ and }B)$.

First, notice $P(A)=P(B)=\frac{12}{42}$. There are $7\cdot 6 =42$ possibilities for what the first (last) two numbers are, but only $6\cdot 2$ of these are consecutive: a consecutive pair is either $x,x+1$ or $x+1,x$, with $6$ choices for $x$.

Similarly, $P(A\text{ and }B)=\frac{10}{210}$. $A$ and $B$ both occur iff the three numbers are of the form $x,x+1,x+2$ or $x+2,x+1,x$, where $x$ is between $1$ and $5$ inclusive. This leads to $5\cdot 2=10$ possibilities, out of a total of $7\cdot 6\cdot 5=210$ possibilities for what all three numbers are.

Therefore, $$P(\text{win})=\frac{12}{42}+\frac{12}{42}-\frac{10}{210} = \frac{110}{210} > \frac12,$$ so you should play this game.

First,

There is no difference if you stop after drawing two consecutive balls as the first two or not. In the end you will have at least two successive consecutive numbers anyway.

So¸

In total there are $7\times6\times5 = 210$ equally probable different outcomes. There are exactly $110$ of them having successive numbers in consecutive positions.
You should play it.

You can

enumerate the cases by considering 1 and 7 consecutive for a minute (later we will subtract those cases which are mistakenly counted only because of this), and using the new symmetry of the system:

- Either the first two numbers are consecutive in $7\times2\times5=70$ cases: the first number can be anything, the second one of the two neighbouring ones, the last one anything of the rest. Note that this includes cases where also the second and third numbers are consecutive.

- Or the first two aren't, but the second and third are consecutive in $7\times4\times2=56$ cases: whatever the first is, the second is one of the four non-neighbouring numbers, the third one of the second's two neighbours (neither of them being the first number).

But now we should remove cases which were miscounted because of the introduced symmetry: 713, 714, 715, 716, 172, 173, 174, 175 and their reversals. That's $70+56-16=110$ in total.

• How did you get the number of winning combinations? – Juan Tomas Aug 29 '16 at 18:55
• @Elias - I came to the same conclusion you did, but wrote out all the possible winning combinations somewhat logically. You can see those in my answer below. It took me much longer to write mine out. :P – Shimizoki Aug 29 '16 at 20:00

Here's a correct answer, but I won't be put out if you don't accept it, because it's brute force. I wrote the following in python:

#!/usr/bin/python

good = 0

for x in range (1, 8):
for y in range (1, 8):
for z in range (1, 8):
if x == y or x == z or y == z:
continue
if abs(x - y) == 1 or abs(x - z) == 1:
good += 1
else:
print (x, y, z, good, bad)


The numbers reveal:

Yes, you should play. There are 210 combinations with no two numbers equal. Of these, 110 combinations have adjacent, consecutive numbers. Odds of winning on any given draw are 11/21, slightly better than even.

• for x, y, z in itertools.product(range(1,8), repeat=3) is quite useful for this kind of thing. – Jonathan Allan Aug 29 '16 at 19:30
• This line is OK if abs(x - y) == 1 or abs(x - z) == 1: because for a win respectively chosen should be consecutive. – z100 Aug 29 '16 at 19:44
• What about abs(y-z) == 1? Include that and you will get the answer @Bohemian posted :) – Jonathan Allan Aug 29 '16 at 19:50
• @Jonathan Allan, see comment under his answer. – z100 Aug 29 '16 at 19:52
• x - z Oof. Typo. Makes the code a little harder to read, but makes no difference to the result. Should be: y - z. – Juan Tomas Aug 29 '16 at 19:57

Chance to Win:

110/210 = 52% - Keep playing

Case 1:

Edge -> Win. (20/210) (1,7) has a 2/7 chance. Win is 1/6. (an edge only has 1 consecutive number.)

Case 2:

Edge -> Edge -> Win (2/210) (1,7) has a 2/7 chance. The other is 1/6. Win is 1/5.

Case 3:

Edge -> Non-Winning Non-Edge -> Win (16/210) (1,7) has a 2/7 chance. Next has 4/6 chance. Win is 2/5.

Case 4:

Non-Edge -> Win (50/210) 2,3,4,5,6 have a 5/7 chance. Next is a 2/6 chance.

Case 5:

Near-Edge -> Non-Winning Edge -> Win (2/210) 2 or 6 have a 2/7 chance. Next (2->7 OR 6->1) is a 1/6 chance. Win is 1/5.

Case 6:

Central -> Edge -> Win (6/210) 3,4,5 have a 3/7 chance. Next is 2/6. Win is 1/5.

Case 7:

Central -> Near-Edge -> Win (4/210) 3,5 have a 2/7 chance. Next (3->6 or 5->2) is 1/6. Win is 2/5

Case 8:

Central -> Non-Edge Non-Near-Edge -> Win (6/210) 3,5 have a 2/7 chance. (3->4/5 or 5->3/4) is 2/6. Win is 2/5

Case 9:

4 -> Near-Edge -> Win (4/210) 4 has a 1/7 chance. Next is 2/6. Win is 2/5

The consecutive numbers should be the 1st and 2nd ball, or the 2nd and 3rd, in both cases, the 2nd is involved, so it's easier for me to picture it as if I pick a ball (the second) and then I have 2 chances to get one consecutive number.

So, if our 2nd ball is a 1 or a 7 (2/7 probability)

Our 1st ball has a 5/6 probability for non-consecutive and our 3rd ball 4/5, resulting in (5/6)·(4/5)= 2/3 probability for non-consecutive, so 1/3 for a consecutive ball.

Same goes for balls form 2 to 6 (5/7 probability).

1st ball will have 4/6 for non-consecutive, and 3rd 3/5, resulting in (4/6)·(3/5)=2/5 for non-consecutive, so 3/5 for consecutive.

Combining all results, our chances are:

(2/7)·(1/3)+(5/7)·(3/5)=11/21

Yes.

Because

The number of distinct combinations of choosing 3 from 7, ie 7C3 is 35, but there are 25 combinations that have consecutive numbers (see below).

So the odds of winning are

The list of winning combinations (generated by brute force using a computer program) is:

[1, 2, 3] [1, 2, 4] [1, 2, 5] [1, 2, 6] [1, 2, 7] [1, 3, 4] [1, 4, 5] [1, 5, 6] [1, 6, 7] [2, 3, 4] [2, 3, 5] [2, 3, 6] [2, 3, 7] [2, 4, 5] [2, 5, 6] [2, 6, 7] [3, 4, 5] [3, 4, 6] [3, 4, 7] [3, 5, 6] [3, 6, 7] [4, 5, 6] [4, 5, 7] [4, 6, 7] [5, 6, 7]

• See the 3rd example. [1, 2, 7] is only wining if 1 and 2 are chosen as 1st and 2nd or 2nd and 3rd, not in case of 1st and 3rd. – z100 Aug 29 '16 at 19:50
• Without the examples in the original question this would be how I'd have understood it. Anyway, here is a non-brute-force way to do the counting: given a non-adjacent triple of numbers from 1..7, subtract 1 from the middle one and 2 from the largest one to give a triple of distinct numbers from 1..5; we can go in the reverse direction too. So the number of non-adjacent triples from 1..7 is (5 choose 3) = 10. – Gareth McCaughan Aug 29 '16 at 20:21
• As @z100 said, order matters in this game, so we should use permutations not combinations. – scott Aug 29 '16 at 22:58
• @scott OP said order doesn't matter in comments under the question. I'm dealing with combinations not permutations. That is, how many ways are there to pick 3. After you've picked 3, check to see if you have at least 2 consecutive. – Bohemian Aug 29 '16 at 23:30
• @z100 OP said order doesn't matter in comments under the question - OP's comment that "you can stop after 2 if they're consecutive" is irrelevant to the math. I'm dealing with combinations not permutations. That is, how many ways are there to pick 3 (ie picking 1,2,7 is treated the same as picking 7,2,1, which is why both are not listed. After you've picked 3, check to see if you have at least 2 consecutive. There are 35 ways of picking 3 of those, 25 have consecutives. – Bohemian Aug 29 '16 at 23:33

There are $\binom{7}{3}=35$ ways to choose $3$ from $7$. Of these, $5$ are all continuous, e.g. $123$, and there are $3!=6$ ways of pulling one of these combinations. There are $20$ methods to pull a $2,1$ combination, e.g,. $124$, namely both sides of any $2$-cont grouping, e.g. $134, 346,347$. There are only $4$ ways to arrange these so that the game can be won, hence the answer is $5\times6+20\times4=30+80=110$.