Advertisement
Guest User

Untitled

a guest
Feb 2nd, 2020
410
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. <?php
  2. $participants = explode(", ", trim(readline()));
  3. $songs = explode(", ", trim(readline()));
  4. $input = readline();
  5. $args = [];
  6. // Vankata, Dragana - Kukavice, Best Srabsko
  7. while ($input != "dawn") {
  8. $command = explode(", ", trim($input));
  9. $singer = $command[0];
  10. $song = $command[1];
  11. $award = $command[2];
  12. if (!in_array($singer, $participants) || !in_array($song, $songs)) {
  13. $input = readline();
  14. continue;
  15. }
  16. if (!key_exists($singer, $args) || !in_array($award, $args[$singer])) {
  17. $args[$singer][] = $award;
  18. }
  19.  
  20.  
  21.  
  22. $input = readline();
  23. }
  24. if (count($args) == 0) {
  25. echo "No awards";
  26. return;
  27. }
  28. arsort($args);
  29. foreach ($args as $key => $item) {
  30. $awardCount = count($item);
  31. echo "$key: $awardCount awards" . PHP_EOL;
  32. foreach ($item as $value) {
  33. echo "--$value" . PHP_EOL;
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement