SHARE
TWEET

05. Walking

MartinGeorgiev Nov 25th, 2018 83 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. $goal = 10000;
  4. $totalSteps = 0;
  5.  
  6. while ($totalSteps < $goal) {
  7.     $command = readline();
  8.     if ($command == "Going home") {
  9.         $currentSteps = intval(readline());
  10.         $totalSteps += $currentSteps;
  11.         break;
  12.     }
  13.     $currentSteps = intval($command);
  14.     $totalSteps += $currentSteps;
  15. }
  16.  
  17. if ($totalSteps >= $goal) {
  18.     echo "Goal reached! Good job!";
  19. } else {
  20.     echo ($goal - $totalSteps) . " more steps to reach goal.";
  21. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top