Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $participants = explode(", ", trim(readline()));
- $songs = explode(", ", trim(readline()));
- $input = readline();
- $args = [];
- // Vankata, Dragana - Kukavice, Best Srabsko
- while ($input != "dawn") {
- $command = explode(", ", trim($input));
- $singer = $command[0];
- $song = $command[1];
- $award = $command[2];
- if (!in_array($singer, $participants) || !in_array($song, $songs)) {
- $input = readline();
- continue;
- }
- if (!key_exists($singer, $args) || !in_array($award, $args[$singer])) {
- $args[$singer][] = $award;
- }
- $input = readline();
- }
- if (count($args) == 0) {
- echo "No awards";
- return;
- }
- ksort($args);
- uasort($args, function ($a, $b) {
- return count($b) - count($a);
- });
- foreach ($args as $key => $item) {
- $awardCount = count($item);
- echo "$key: $awardCount awards" . PHP_EOL;
- sort($item);
- foreach ($item as $value) {
- echo "--$value" . PHP_EOL;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement