Skip to content

Instantly share code, notes, and snippets.

@anushshukla
Created June 6, 2019 06:21
Show Gist options
  • Save anushshukla/f436c90b9bc948c33d7fd15c7380e5fc to your computer and use it in GitHub Desktop.
Save anushshukla/f436c90b9bc948c33d7fd15c7380e5fc to your computer and use it in GitHub Desktop.
Get Jump Attempts
<?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