A forager sorts a basket of mushrooms with one yes/no question about each, like “Does it have a ring on the stem?”. The answer sorts the basket into left (yes) and right (no), each a list of labels: "toxic" or "safe". Before the question, telling whether a random mushroom is toxic takes some yes/no questions on average (“How surprising?”); once you know its side, it may take fewer. Write split_score(left, right): how many yes/no questions the question saved, on average. Count them in bits, as in “How surprising?”: one bit is one yes/no question.
Eight mushrooms, four of them toxic. The forager asks “Does it have a ring on the stem?”, and each mushroom goes left (yes) or right (no). Your function says how many yes/no questions that saved, on average.
how many questions did it save? that’s for you to work out
split_score(left, right)| left | the labels ("toxic" or "safe") on each side | e.g. ["toxic", "safe"] |
| right | the labels ("toxic" or "safe") on each side | e.g. ["toxic", "safe", "toxic", "safe"] |
| returns | how many yes/no questions the split saved, on average | |