| Next | You can't get there from here | 31 |
sub travelling_salesman {
my ($cities, $airfare, $budget) = @_;
for my $itinerary (all_permutations($cities)) {
if (cost_of($airfare, @$itinerary) < $budget) {
return $itinerary;
}
}
return undef;
}
How long does this take?
There are a lot of possible itineraries
3 6
4 24
5 120
6 720
continued...
| Next | ![]() |
Copyright © 2005 M. J. Dominus |