diff options
author | Jesse Luehrs <doy@tozt.net> | 2009-05-14 22:03:52 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2009-05-14 22:05:29 -0500 |
commit | baf7fba4e16efce1aa8e4ffdc75a9430ef5858a7 (patch) | |
tree | adeeec35d4fd0befc4ed1813f302e9c537ebadda | |
parent | f37c40b2ea0471760c12f04951f5f8ee54af6bc7 (diff) | |
download | projecteuler-baf7fba4e16efce1aa8e4ffdc75a9430ef5858a7.tar.gz projecteuler-baf7fba4e16efce1aa8e4ffdc75a9430ef5858a7.zip |
clean up 18 a bit
-rwxr-xr-x | 018.pl | 7 |
1 files changed, 3 insertions, 4 deletions
@@ -24,19 +24,18 @@ my $triangle_txt = <<'TRIANGLE'; TRIANGLE my @triangle_lines = split /\n/, $triangle_txt; my @triangle = map { [split ' ', $_] } @triangle_lines; -use DDS; my $graph = Graph::Implicit->new(sub { my ($vx, $vy) = split ' ', shift; return if $vx == @triangle - 1; - #print "$vx, $vy -> ", $vx + 1, ", $vy and ", $vx + 1, ", ", $vy + 1, "\n"; return ([($vx + 1) . " " . $vy, 100 - $triangle[$vx + 1][$vy]], [($vx + 1) . " " . ($vy + 1), 100 - $triangle[$vx + 1][$vy + 1]]); }); my ($paths, $blah) = $graph->dijkstra("0 0"); my @paths; -for my $i (0..14) { - push @paths, [Graph::Implicit::make_path($paths, "14 $i")]; +my $bottom_row = @triangle - 1; +for my $i (0..$bottom_row) { + push @paths, [Graph::Implicit::make_path($paths, "$bottom_row $i")]; } my @path_values = map { [map { my ($x, $y) = split; $triangle[$x][$y] } @$_] } @paths; |