3 min read

Can You Slice The Ice?

Table of Contents

Riddler Express

I have a most peculiar menorah. Like most menorahs, it has nine total candles β€” a central candle, called the shamash, four to the left of the shamash and another four to the right. But unlike most menorahs, the eight candles on either side of the shamash are numbered. The two candles adjacent to the shamash are both β€œ1,β€β€œ1,” the next two candles out from the shamash are β€œ2,β€β€œ2,” the next pair are β€œ3,β€β€œ3,” and the outermost pair are β€œ4.β€β€œ4.”

The shamash is always lit. How many ways are there to light the remaining eight candles so that sums on either side of the menorah are β€œbalanced”? (For example, one such way is to light candles 11 and 44 on one side and candles 22 and 33 on the other side. In this case, the sums on both sides are 55, so the menorah is balanced.)

Computational solution

The number of ways of lighting the candles satisfying the conditions is 25\textbf{25}. The different ways of lighting the candles is given below:

(('l', 1), ('r', 1))
(('l', 2), ('r', 2))
(('l', 3), ('r', 3))
(('l', 4), ('r', 4))
(('l', 1), ('l', 2), ('r', 3))
(('l', 1), ('l', 3), ('r', 4))
(('l', 3), ('r', 1), ('r', 2))
(('l', 4), ('r', 1), ('r', 3))
(('l', 1), ('l', 2), ('r', 1), ('r', 2))
(('l', 1), ('l', 3), ('r', 1), ('r', 3))
(('l', 1), ('l', 4), ('r', 1), ('r', 4))
(('l', 1), ('l', 4), ('r', 2), ('r', 3))
(('l', 2), ('l', 3), ('r', 1), ('r', 4))
(('l', 2), ('l', 3), ('r', 2), ('r', 3))
(('l', 2), ('l', 4), ('r', 2), ('r', 4))
(('l', 3), ('l', 4), ('r', 3), ('r', 4))
(('l', 1), ('l', 2), ('l', 3), ('r', 2), ('r', 4))
(('l', 1), ('l', 2), ('l', 4), ('r', 3), ('r', 4))
(('l', 2), ('l', 4), ('r', 1), ('r', 2), ('r', 3))
(('l', 3), ('l', 4), ('r', 1), ('r', 2), ('r', 4))
(('l', 1), ('l', 2), ('l', 3), ('r', 1), ('r', 2), ('r', 3))
(('l', 1), ('l', 2), ('l', 4), ('r', 1), ('r', 2), ('r', 4))
(('l', 1), ('l', 3), ('l', 4), ('r', 1), ('r', 3), ('r', 4))
(('l', 2), ('l', 3), ('l', 4), ('r', 2), ('r', 3), ('r', 4))
(('l', 1), ('l', 2), ('l', 3), ('l', 4), ('r', 1), ('r', 2), ('r', 3), ('r', 4))
from itertools import product, combinations

def menorah_lighting(n=4):
    side_sum = lambda comb, side: sum([i for s, i in comb if s == side])
    candles = list(product(["l","r"], range(1, n+1)))
    cnt, lightings = 0, []
    for k in range(2, 2*n+1):
        for comb in combinations(candles, k):
            if side_sum(comb, "l") == side_sum(comb, "r"):
                lightings.append(comb)
                cnt += 1 
    return cnt, lightings

cnt, lightings = menorah_lighting()
print(cnt)
for l in lightings:
    print(l)