Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # use warnings;
- open(my $fin, '<', "input.txt") or die "Issue";
- my @row = <$fin>;
- open($fout, '>', "output.txt") or die "Issue";
- my $amount = @row[0] + 0; my $curpose = 1;
- my @animals = [];
- @animals["lol"] = !defined(@animals["lol"]) ? 1 : (@animals["lol"] < 2 ? 2 : @animals["lol"]);
- @animals["lol"] = 0;
- print @animals["lol"];
- while($curpose < scalar @row){
- my @currentList = [];
- $num = @row[$curpose] + 0;
- for (my $j = 1; $j <= $num + 0; $j++){
- $name = @row[$j + $curpose];
- chomp $name;
- print $name;
- if (!defined(@currentList[$name])){ @currentList[$name] = 0;}
- else {@currentList[$name] = @currentList[$name] + 1;}
- @animals[$name] = !defined(@animals[$name]) ? 1 : (@animals[$name] < @currentList[$name] ? @currentList[$name] : @animals[$name]);
- print @animals[$name], "\n";
- }
- # print $curpose, " ", @row[$curpose]; print "\n";
- $curpose += @row[$curpose] + 1;
- }
- $amount = 0;
- # foreach $animal (@animals){
- # # print "$animal \n";
- # $amount += $animal;
- # }
- # print @animals["Lionhead"];
- # print @animals["Pearlscale"];
- print $fout $amount;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement