A probability problem by Swadesh Rath

There are four basket-ball players A, B, C, D. Initially, the ball is with A. The ball is always passed from one person to a different person. In how many ways can the ball come back to A after seven passes? (For example A → C → B → D → A → B → C → A and A → D → A → D → C → A → B → A are two ways in which the ball can come back to A after seven passes.)


The answer is 546.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

2 solutions

Saharsh Rathi
Oct 31, 2016

I started from the 7th pass and kept making all the cases backwards .

Bill Bell
Nov 9, 2015

Not only do I know how many there are I can say what they are. (Not that that matters.)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
from copy import copy

def build(chain):
    global count
    end=chain[-1]
    possibleLinks='ABCD'.replace(end,'')
    for nextLink in possibleLinks:
        if len(chain)==7:
            if nextLink=='A':
                print '%s%s' % (chain, nextLink)
                count+=1
            return
        elif len(chain)>6:
            return
        else:
            build(copy(chain)+nextLink)

count=0
build('A')

print count

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...