Combinatorial implementation and puzzle

enter image description here

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.

+5
source share
1 answer

There are 7! ways to line up children (7 options for first place, 6 for second, 5 for third, etc.)

. . 2 ** 7. (.. 2 ).

, , " " . 7 , , 7.

2 ** 7 * 7!/7 = 128 * 6!= 92160.

+6

All Articles