Created
June 6, 2019 06:21
-
-
Save anushshukla/f436c90b9bc948c33d7fd15c7380e5fc to your computer and use it in GitHub Desktop.
Get Jump Attempts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function getJumpAttempts($maxJump,$slipsBy,$wallHeights) | |
{ | |
$attempts = 0; | |
foreach($wallHeights as $wallHeight) { | |
$attempts++; | |
do { | |
if($wallHeight > $maxJump) { | |
$wallHeight -= $maxJump - $slipsBy; | |
} else { | |
$wallHeight -= $maxJump; | |
break; | |
} | |
$attempts++; | |
} while ($wallHeight - $maxJump > 0); | |
} | |
return $attempts; | |
} | |
// echo getJumpAttempts(10,1,[10]); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment