Filling numbers in 19 cells set in a big hexagon such that....

166 Views Asked by At

In social groups this question (see the photo below) of filling integers in 19 small cells set in a big hexagon is asked, such that their sum in each layer(row) in all three directions is 50. Next, it asks one to find the sum of numbers in 7 pink cells.

I named 19 unknowns row wise as $A_1,A_2,A_3; B_1,B_2,B_3,B_4; C_1, C_2,C_3,C_4, C_5; D_1,D_2,D_3,D_4; E_1, E_2, E_3$ and set up 15 linear simultaneous equations. I solved this system of consistent linear simultaneous equations at Mathematica to get values of 15 unknowns in terms of 4 of them to find that sum of numbers in pink cells: $A_1+A_3+C_1+C_3+C_5+E_1+E_3=$constant.

The question is: What is this constant and how to get it other wise?

enter image description here

2

There are 2 best solutions below

0
On BEST ANSWER

If you add up all six rows of length $4$, you get exactly double the blue cells (each cell is covered twice). Hence the blue cells total $150$. Since the entire hexagon totals $250$, the pink cells must total $100$.

3
On

I bet the original solution will be something like this:

"The sums along blue lines minus the sums along red lines are two times the desired sum."
(Btw, the constant is now obvious, since the sum of blue lines is $50\cdot 6$ and the sum of red lines $50\cdot 2$ so the constant is $50\cdot \dfrac{6-2}{2}$)

You don't want to know how this is achieved,
in short, yes, the linear system $Ax=b$, then $yA^T=t$ (where $t$ consists of $1$ for target (pink) variables, $0$ for others) feeds to WA, WA produces $3$ free variables solution ($y$) and we minimize the number of non-$0$ coefficients.
the python source:


from sympy import *
import itertools
from functools import reduce
import re
R=Rational
transitions=[(1,2),(2,0)]
t1=set((a*i,b*j) for i,j in transitions
    for a,b in itertools.product([-1,1],repeat=2))
assert len(t1)==6
t2=set((a+b,c+d) for (a,c),(b,d) in itertools.product(t1,repeat=2))
assert len(t1|t2)==19
_all=sorted(t1|t2,key=lambda x:x[::-1])
coords=[(R(i),j*sqrt(R(3))/R(2)) for i,j in _all]
_dict={i:n for n,i in enumerate(coords)}
cut=lambda l,c:reduce(lambda x,y:(x[0]+[x[1][:y]],x[1][y:]),c,([],l))[0]
rot=[[(a*i+b*j,-b*i+a*j) for i,j in coords] for a,b in
     [(R(1),R(0)),(R(1,2),sqrt(R(3))/R(2)),(R(1,2),-sqrt(R(3))/R(2))]]
assert all(j in _dict for i in rot for j in i)
_n=[[_dict[k] for k in j] for i in rot for j in cut(i,[3,4,5,4,3])]
target=[0,2,18-0,18-2,9,9+2,9-2]
_m=[[[0,1][j in i] for j in range(19)] for i in _n+[target]]
_l=''.join(chr(ord('a')+n) for n,i in enumerate(_m))
#print(', '.join('%s == 1'%(' + '.join(_l[j] for j in i)) for i in _n))
#at this point we simply feed the output into WA, producing the result in s
print(', '.join('%s == %d'%(' + '.join(
    _l[n] for n,j in enumerate(i[:-1]) if j),i[-1])
                for i in zip(*_m)))
s=r'''c == 1 - a + 2*b && d == 1 - 2*a + 3*b && e == 2 - 3*a + 4*b && g == -1 + a - b + f && h == -1 + 2*a - 2*b + f && i == -2 + 3*a - 3*b + f && j == -2 + 4*a - 4*b + f && k == 2 - 3*a + 2*b - f && l == 1 - 2*a + b - f && m == 1 - a - f && n == -b - f && o == a - 2*b - f'''
s=list(zip(*(i.split(' == ') for i in s.split(' && '))))
matcher=re.compile(r'\d+')
s,_v='(%s)'%(', '.join(matcher.sub((lambda m:'R(%s)'%(m.group(0))),i)
                       for i in s[1])),s[0]
_f=lambda a,b,f:eval(s)
x=min(
#i for i in
itertools.product([R(j,12) for j in range(-24,25)],repeat=3),
key=lambda i:sum(j!=R(0) for j in _f(*i)+i)
)
print(x,_f(*x))
#print(
assert all(
    [(sum(_m[_l.index(v)][k]*j
        for j,v in zip(x+_f(*x),('a','b','f')+_v))
     ==_m[-1][k])
      for k in range(19)]
)
for j,v in zip(x+_f(*x),('a','b','f')+_v):
    if j!=0:
        print(j,_n[_l.index(v)])