
'Fruit grid sums
================
'http://community.wolfram.com/groups/-/m/t/307516?p_p_auth=vHs9FlgA

'MANUAL OPTIMISATIONS
'limes=6 [y5]
'pear+avocado=8 [y3]
'melon+cherry+strawberry+apple=18 [y2]
'banana+melon+pine+pine+apple=22 [x1]


'RUN PERMUTATIONS
sys ok
'   lime,apple,pear,avocado,melon,cherry,strawberry,banana,grape,pineapple
sys li,ap,pe,av,me,ch,st,ba,gr,pn
li=6
for pe=0 to 9
for av=0 to 9
if pe+av=8 then
for ap=0 to 9
for me=0 to 9
for ch=0 to 9
for st=0 to 9
if me+ch+st+ap=18 then
for ba=0 to 9
for gr=0 to 9
for pn=0 to 9
  'row tests
  if ba+st+gr+ap+pn+pe<>26 then jmp fwd ns
  if me+av+ch+st+pe+ap<>26 then jmp fwd ns
' if av+pe+av+pe+av+pe<>24 then jmp fwd ns
  if pn+ch+st+ba+me+gr<>22 then jmp fwd ns
' if li+li+li+li+li+li<>36 then jmp fwd ns
  if ap+ba+pn+ch+ba+st<>30 then jmp fwd ns
  if pe+me+gr+st+me+ch<>19 then jmp fwd ns
  if pn+av+ba+ch+pe+gr<>23 then jmp fwd ns
  'column tests
  if ba+me+av+pn+li+ap+pe+pn<>35 then jmp fwd ns
  if st+av+pe+ch+li+ba+me+av<>38 then jmp fwd ns
  if gr+ch+av+st+li+pn+gr+ba<>36 then jmp fwd ns
  if ap+st+pe+ba+li+ch+st+ch<>34 then jmp fwd ns
  if pn+pe+av+me+li+ba+me+pe<>31 then jmp fwd ns
  if pe+ap+pe+gr+li+st+ch+gr<>32 then jmp fwd ns
  ok=1 : jmp fwd done
  ns:
next
next
next
end if
next
next         
next
next
end if
next
next

'RESULTS
done:
if not ok then
  print "no solution"
else
print " 
lime " li "
apple " ap "
pear " pe "
avocado " av "
melon " me "
cherry " ch "
strawberry " st "
banana " ba "
grape " gr "
"
end if