A tiny correction in the following:
if (position + adjustedSpeed in memo and
adjustedSpeed in memo[position + adjustedSpeed] and
adjustedSpeed in memo[position + adjustedSpeed]):
The middle line is not needed.