Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $input = readline();
- $arr = preg_replace('/\s+/', '', $input);
- $args = explode(",", $arr);
- $pattern = '/(\@{6,}|\${6,}|\^{6,}|\#{6,})/';
- for ($i = 0; $i < count($args); $i++) {
- $tikets = $args[$i];
- if (strlen($tikets) != 20) {
- echo "invalid ticket\n";
- continue;
- }
- if (preg_match($pattern, $tikets, $match)) {
- $left = $match[0];
- $right = $match[1];
- $symbol = substr($left, 0, 1);
- if (strlen($left) >= 10) {
- $sum = strlen($left)/2;
- echo "ticket \"$tikets\" - " . $sum, $symbol . " Jackpot!\n";
- }else{
- $sum = strlen($left);
- echo "ticket \"$tikets\" - " . $sum, $symbol . "\n";
- }
- } else {
- echo "ticket \"$tikets\" - no match";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement