Is the sample solution just hardcoded or is there some maths behind it to make it work from any location/initial speed?