RouteOne interview question

How would you solve this code challenge?