
Found this puzzle inside the image. In my opinion, the total number of ways should be
2*comb(7,i) for i <- 1 to 7where is combdefined as follows. Is my approach right? I am concerned about the result I got, not the function written below.
def comb(N,k):
if (k > N) or (N < 0) or (k < 0):
return 0L
N,k = map(long,(N,k))
top = N
val = 1L
while (top > (N-k)):
val *= top
top -= 1
n = 1L
while (n < k+1L):
val /= n
n += 1
return val
Don't mind me asking too many questions in a short amount of time. I'm just thrilled.
source
share