Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $name = readline();
- $startPoints = 301;
- $success = 0;
- $fails = 0;
- $hasRetired = false;
- while ($startPoints > 0) {
- $field = readline();
- if ($field == "Retire") {
- $hasRetired = true;
- break;
- }
- $points = intval(readline());
- switch ($field) {
- case "Double":
- $points *= 2;
- break;
- case "Triple":
- $points *= 3;
- break;
- }
- if ($points > $startPoints) {
- $fails++;
- } else {
- $success++;
- $startPoints -= $points;
- }
- }
- if ($hasRetired) {
- echo "$name retired after $fails unsuccessful shots.";
- } else {
- echo "$name won the leg with $success shots.";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement