heuristic function for missionaries and cannibals problem