working calculate distance soln in rb