Completing the reshape function in distance.py