Thursday, October 22, 2015

PuzzlOR: Chandelier Balance

chandelier1
In [1]:
import itertools
from time import process_time

Balance Equations for the Chandelier:

$$ \begin{align} 2a & =b+2c \\ f & =e+2d \\ 3i & =h+2g \\ 3(a+b+c) & =2(d+e+f)+3(g+h+i) \end{align} $$
In [2]:
t=process_time()

# Examine every possible permutation to find the one that satisfies the balance equations
for config in itertools.permutations([1,2,3,4,5,6,7,8,9]):
    a,b,c,d,e,f,g,h,i=config
    if (2*a==b+2*c) and (f==e+2*d) and (3*i==h+2*g) and (3*(a+b+c)==2*(d+e+f)+3*(g+h+i)) :
        print(config)

elapsed_time=process_time()-t        
print("Elapsed Time: ", elapsed_time)
(9, 4, 7, 1, 6, 8, 2, 5, 3)
Elapsed Time:  0.5750594800000001