Let n and k be fixed positive integers of the same parity, k >= n. We are given 2n lamps numbered 1 through 2n; each of them can be on or off. At the beginning all lamps are off. We consider sequences of k steps. At each step one of the lamps is switched (from off to on or from on to off). * Let N be the number of k-step sequences ending in the state: lamps 1, ..., n on, lamps n+1, ..., 2n off. * Let M be the number of k-step sequences leading to the same state and not touching lamps n+1, ..., 2n at all. Find the ratio N/M. ========================================= It makes sense that k,n must be of the same parity, otherwise, there is no sequence of switches -- the parity of the lamps turned on in the end equals the parity of the number of steps (= k). Experiments: n = 1, k = 1 -> one sequence ... in general, if k = n, the ratio N/M is one because every sequence turning on the lamps 1, ..., n have to touch each of these lamps exactly once and does not have time to touch the lamps n+1, ..., 2n By the way, M = N = n! n = 1, k = 3: * N: (1,1,1), (1,2,2), (2,1,2), (2,2,1) * only one of the sequences counts for M: (1,1,1) * N/M = 4 n = 1, k = 5: * 11111, 22221, 21221, ... * in general, if n = 1, then M = 1 (only swapping lamp1) and N = 2^(k-1) because we can choose any first k-1 steps, and then we are forced to choose a given lamp at the end by parity. n = 2, k = 4 * M: 1112, 1121, 1211, 2111, 2221, 2212, 2122, 1222: 8 sequences * N-M: 12xx for x=3,4, and 4*3 possible positions of 1,2, that is 24 sequences * N = 32 * N/M = 4 Hm... Maybe N/M is always 2^(k-n). (it fits the experiments so far) How to prove it... I have an M-sequence, and I would produce 2^(k-n) N-sequences out of it. Or maybe, I can produce 2^k objects out of an M-sequence, and 2^n objects out of an N-sequence so that the objects are unique, and they are the same in both cases. N-sequence, 1...2^n -> ? * 2^n represents a subset of {1,2,...,n} * So the combination is something like initial state of the first n lamps, and the sequence * or perhaps the subset of {1,2,...,n} encodes some swapping of the lamp i with i+n? M-sequence, 1...2^k -> ? * 2^k represents a subset of {1,2,...,k}, that is the subset of steps * I could alter the steps of the subset in a way, let's say change i -> i+n. * So for example sequence (1,2,1,1) + subset(0,1,0,1) -> sequence (1,4,1,3) * What is the property of such a sequence? In the end, the lamps (3,4) are lighting. * In general, after such modification of the sequence, we always get a sequence in which exactly one of the lamps (i, i+n) is on because the parity of lamps which are on among (i, i+n) remains the same as in the original sequence. * This is promissing. So the destination object is a k-sequence such that after performing the steps, for every i = 1...n, exactly one lamp of (i,i+n) is on, let's call it D-sequence. We have already described a bijection (M-sequence, subset of {1...k}) -> D-sequence. * (the reverse mapping is obvious, just subtract n from every step touching a lamp > n) Now, the bijection (N-sequence, subset of {1...n}) -> D-sequence. * For every i in the subset, make a replacement in the sequence i <-> i+n at every position * Or at the first position? Maybe it could also work but I like every position more now. * So for example: N-sequence (4,2,1,4), subset {2} -> (2,4,1,2) * It apparently leads to a D-sequence. * Reversely, given a D-sequence, we look at which lamps are on in the end of the D-sequence from that, we read the subset of {1...,n}, and perform the reverse replacement. QED, N/M = 2^(k-n) Problem Solved!