Advertisement
Guest User

Untitled

a guest
Sep 2nd, 2019
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. <?php
  2. $input = readline();
  3. $arr = preg_replace('/\s+/', '', $input);
  4. $args = explode(",", $arr);
  5. $pattern = '/(\@{6,}|\${6,}|\^{6,}|\#{6,})/';
  6. for ($i = 0; $i < count($args); $i++) {
  7. $tikets = $args[$i];
  8. if (strlen($tikets) != 20) {
  9. echo "invalid ticket\n";
  10. continue;
  11. }
  12. if (preg_match($pattern, $tikets, $match)) {
  13. $left = $match[0];
  14. $right = $match[1];
  15. $symbol = substr($left, 0, 1);
  16. if (strlen($left) >= 10) {
  17. $sum = strlen($left)/2;
  18. echo "ticket \"$tikets\" - " . $sum, $symbol . " Jackpot!\n";
  19. }else{
  20. $sum = strlen($left);
  21. echo "ticket \"$tikets\" - " . $sum, $symbol . "\n";
  22. }
  23.  
  24. } else {
  25. echo "ticket \"$tikets\" - no match";
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement