Advertisement
Guest User

Darts

a guest
Apr 18th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.95 KB | None | 0 0
  1. $player1 = readline();
  2. $StartPoints = 301;
  3. $result = 0;
  4. $count = 0;
  5. $uncount = 0;
  6. while (1) {
  7.     $sector = readline();
  8.     $points = intval(readline());
  9.     if ($sector != 'Retire') {
  10.         if ($sector == 'Single' && $points <= $StartPoints) {
  11.             $StartPoints -= $points;
  12.             $count++;
  13.         }
  14.         if ($sector == 'Double' && $points <= $StartPoints) {
  15.             $points *= 2;
  16.             $StartPoints -= $points;
  17.             $count++;
  18.         }
  19.         if ($sector == 'Triple' && $points <= $StartPoints) {
  20.             $points *= 3;
  21.             $StartPoints -= $points;
  22.             $count++;
  23.         }
  24.         if ($StartPoints == 0) {
  25.             echo"$player1 won the leg with $count shots.";
  26.             return;
  27.         }
  28.         if ($points > $StartPoints) {
  29.            $StartPoints=$StartPoints;
  30.             $uncount++;
  31.         }
  32.     } else {
  33.         echo"$player1 retired after $uncount unsuccessful shots.";
  34.         return;
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement