Hi,
rules = {"banana" -> a, "strawberry" -> b, "grapes" -> c, "apple" -> d, "pineapple" -> e, "pear" -> f, "melon" -> g ,
"avocado" -> h, "cherry" -> i, "lemon" -> j}
the matrix of fruits is:
matrix = Flatten[{{{a}, {b}, {c}, {d}, {e}, {f}}, {{g}, {h}, {i}, \
{b}, {f}, {d}}, {{h}, {f}, {h}, {f}, {h}, {f}}, {{e}, {i}, {b}, {a}, \
{g}, {c}}, {{j}, {j}, {j}, {j}, {j}, {j}}, {{d}, {a}, {e}, {i}, {a}, \
{b}}, {{f}, {g}, {c}, {b}, {g}, {i}}, {{e}, {h}, {a}, {i}, {f}, \
{c}}}, {1, 3}]
We then need the sums at the right and the bottom:
A = {26, 26, 24, 22, 36, 30, 19, 23};
B = {35, 38, 36, 34, 31, 32};
Up to now it was just setting up the problem. Here is the solution:
Solve[Flatten[{Total /@ matrix == A, (Total /@ Transpose[matrix]) ==B}], {a, b, c, d, e, f, g, h, i, j}] /. (Reverse /@ rules)
banana->8, strawberry->3, grapes->5, apple->9,
pineapple->0, pear->1, melon->4, avocado->7,
cherry->2, lemon->6
I might have made a mistake typing this. It seems to be more an exercise in typing than in Mathematica. It would certainly have helped to have your notebook with the matrix in it.
Cheers,
Marco