Car refueling problem program algorithm