diff options
| author | robbie-hatley <Robbie.Hatley@gmail.com> | 2024-09-26 17:52:24 -0700 |
|---|---|---|
| committer | robbie-hatley <Robbie.Hatley@gmail.com> | 2024-09-26 17:52:24 -0700 |
| commit | ac1ebe39431a887d9d8d3f64ce7fc204d516bdfc (patch) | |
| tree | 4f8d41b1f0bceba6d0719ead988bf27a3794f325 | |
| parent | eb0dafab169e0a3675346f4f7b65d806c400bcf5 (diff) | |
| download | perlweeklychallenge-club-ac1ebe39431a887d9d8d3f64ce7fc204d516bdfc.tar.gz perlweeklychallenge-club-ac1ebe39431a887d9d8d3f64ce7fc204d516bdfc.tar.bz2 perlweeklychallenge-club-ac1ebe39431a887d9d8d3f64ce7fc204d516bdfc.zip | |
Simplified block merging in 288-2.
| -rwxr-xr-x | challenge-288/robbie-hatley/perl/ch-2.pl | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/challenge-288/robbie-hatley/perl/ch-2.pl b/challenge-288/robbie-hatley/perl/ch-2.pl index af145b8a63..2159834b6e 100755 --- a/challenge-288/robbie-hatley/perl/ch-2.pl +++ b/challenge-288/robbie-hatley/perl/ch-2.pl @@ -152,12 +152,9 @@ sub max_contiguous_block_size ($mref) { # If we get to here, current AND neighbor already have block numbers. # If they're the same, take no action: next if $ids{$ne} == $ids{$id}; - # Otherwise, assign the lesser block number to all cells with the greater block number: - my ($l, $g); - if ($ids{$id}<$ids{$ne}) {$l = $ids{$id}; $g = $ids{$ne};} - if ($ids{$id}>$ids{$ne}) {$g = $ids{$id}; $l = $ids{$ne};} + # Otherwise, assign the neighbor's block number to all cells with the current block number: for my $key (keys %ids) { - if ($ids{$key} == $g) {$ids{$key} = $l;} + if ($ids{$key} == $ids{$id}) {$ids{$key} = $ids{$ne};} } } } |
