diff options
| author | drbaggy <js5@sanger.ac.uk> | 2021-06-28 07:24:31 +0100 |
|---|---|---|
| committer | drbaggy <js5@sanger.ac.uk> | 2021-06-28 07:24:31 +0100 |
| commit | 51437f2806e2d54152f101af72cb9b930afc1fd3 (patch) | |
| tree | 8da80e6a060e2005ba9b0eb5b28e176bcb965feb /challenge-118 | |
| parent | 9f5b8d4b7eabd14a7b61624ebfbd7dc5d3674006 (diff) | |
| download | perlweeklychallenge-club-51437f2806e2d54152f101af72cb9b930afc1fd3.tar.gz perlweeklychallenge-club-51437f2806e2d54152f101af72cb9b930afc1fd3.tar.bz2 perlweeklychallenge-club-51437f2806e2d54152f101af72cb9b930afc1fd3.zip | |
tweaks to code to not use look ups for routes until display
Diffstat (limited to 'challenge-118')
| -rw-r--r-- | challenge-118/james-smith/perl/ch-2-using-precomputed-distances.pl | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/challenge-118/james-smith/perl/ch-2-using-precomputed-distances.pl b/challenge-118/james-smith/perl/ch-2-using-precomputed-distances.pl index 134a4f1db1..99709ee952 100644 --- a/challenge-118/james-smith/perl/ch-2-using-precomputed-distances.pl +++ b/challenge-118/james-smith/perl/ch-2-using-precomputed-distances.pl @@ -78,13 +78,15 @@ my $time_3 = time; say ''; say 'Minimal length: ',$ln; say 'Minimal route: a8 ',show_rt( $rt ); +$rt = join '', map { $route_maps->[$start][$start = ord $_] } split //,$rt; + +say 'Minimal route: a8 ',show_rt( $rt ); say ''; my $p = 1; $p*=$_ foreach 1..@treasures; say 'Permutations: ',$p; say 'Function calls: ',$calls; say 'Cache entries: ',scalar keys %CACHE; -say 'Speed up: ',$p/scalar keys %CACHE; say ''; say 'Timings:'; say sprintf 'Pre^2-compute: %9.6f',$time_1-$time_0; @@ -112,7 +114,7 @@ sub optimal_route { my $l = $dist_maps->[$start][$t] + $x->[0]; if( $l < $len ) { $len = $l; - $rt = $route_maps->[$start][$t] . $x->[1]; + $rt = (chr $t).$x->[1]; } push @r,$t; } |
