Advertisement
Guest User

asdfasdf

a guest
Sep 29th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 1.08 KB | None | 0 0
  1. # use warnings;
  2. open(my $fin, '<', "input.txt") or die "Issue";
  3. my @row = <$fin>;
  4.  
  5. open($fout, '>', "output.txt") or die "Issue";
  6. my $amount = @row[0] + 0; my $curpose = 1;
  7. my @animals = [];
  8. @animals["lol"] = !defined(@animals["lol"]) ? 1 : (@animals["lol"] < 2 ? 2 : @animals["lol"]);
  9. @animals["lol"] = 0;
  10. print @animals["lol"];
  11. while($curpose < scalar @row){
  12.     my @currentList = [];
  13.     $num = @row[$curpose] + 0;
  14.     for (my $j = 1; $j <= $num + 0; $j++){
  15.         $name = @row[$j + $curpose];
  16.         chomp $name;
  17.         print $name;
  18.         if (!defined(@currentList[$name])){ @currentList[$name] = 0;}
  19.         else {@currentList[$name] =  @currentList[$name] + 1;}  
  20.         @animals[$name] = !defined(@animals[$name]) ? 1 : (@animals[$name] < @currentList[$name] ? @currentList[$name] : @animals[$name]);
  21.         print @animals[$name], "\n";
  22.     }
  23.     # print $curpose, " ", @row[$curpose]; print "\n";
  24.     $curpose += @row[$curpose] + 1;
  25.    
  26. }
  27. $amount = 0;
  28. # foreach $animal (@animals){
  29.     # # print "$animal \n";
  30.     # $amount += $animal;
  31. # }
  32. # print @animals["Lionhead"];
  33. # print @animals["Pearlscale"];
  34. print $fout $amount;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement