The key must be whole.
transcript
A cache key can be too small. Then the answers are wrong. No error is shown. The code still runs fast.
A robot moves down or right. The grid is three by three. The answer is twenty routes. We counted them by running the code.
The key is down alone. The cache mixes up problems. It returns forty routes. The whole key returns twenty.
Down is three in many calls. But right is different. They share one entry. So one problem gets the other answer.
List every argument of the function. Cross out any that never matter. Use the rest as the key. Test it against the plain version. Here the key is both distances.
List the arguments. Cross out the extras. Keep every one that matters. Never share an entry by mistake.
A small key lies. Test against the plain version. Compare the answers on small inputs. Full breakdown in the lecture.