Can You Slice The Ice?

A FiveThirtyEight Riddler puzzle.

By Vamshi Jandhyala in mathematics Riddler

December 3, 2021

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,”$ the next two candles out from the shamash are $“2,”$ the next pair are $“3,”$ and the outermost pair are $“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 $1$ and $4$ on one side and candles $2$ and $3$ on the other side. In this case, the sums on both sides are $5$, so the menorah is balanced.)

Computational solution

The number of ways of lighting the candles satisfying the conditions is $\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)