({route, pickUp})
| 15 | // Route length counts negatively, routes that pick up a package |
| 16 | // get a small bonus. |
| 17 | function score({route, pickUp}) { |
| 18 | return (pickUp ? 0.5 : 0) - route.length; |
| 19 | } |
| 20 | route = routes.reduce((a, b) => score(a) > score(b) ? a : b).route; |
| 21 | } |
| 22 |