Advertisement
harmth

Untitled

Dec 3rd, 2018
393
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.52 KB | None | 0 0
  1. #!/usr/bin/perl
  2. use 5.026;
  3.  
  4. my %patch;
  5. my $double;
  6. my %claims;
  7.  
  8. while (<>) {
  9.     my (undef, $id, $l, $t, $w, $h) = split /[#@,:x ]+/;
  10.     $claims{$id} = 1;
  11.     for (my $x = $l; $x < $l+$w; $x++) {
  12.         for (my $y = $t; $y < $t+$h; $y++) {
  13.             if ($patch{$x}{$y}) {
  14.                 $double++;
  15.                 delete $claims{$patch{$x}{$y}};
  16.                 delete $claims{$id};
  17.             } else {
  18.                 $patch{$x}{$y} = $id;
  19.             }
  20.         }
  21.     }
  22. }
  23.  
  24. say $double;
  25. say keys %claims;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement