Skip to content

Instantly share code, notes, and snippets.

@lbvf50mobile
Last active July 20, 2020 16:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lbvf50mobile/55c3ea90b334eecb918d480c677d04e8 to your computer and use it in GitHub Desktop.
Save lbvf50mobile/55c3ea90b334eecb918d480c677d04e8 to your computer and use it in GitHub Desktop.
Just PHP FUN 054.
# https://www.codewars.com/kata/5896616336c4bad1c50000d7 Area of an annulus.
function annulus_area(int $a): float {
return round(($a/2)**2*pi(),2);
}
<?php
# https://www.codewars.com/kata/589478160c0f8a40870000bc Area of an arrow.
function arrow_area(int $a, int $b): float {
return $a*$b/4;
}
<?php
# https://www.codewars.com/kata/5813d19765d81c592200001a Don't give me five!
function dont_give_me_five($start, $end) {
return count(array_filter(range($start,$end),function($x){ return false === strpos(strval($x),'5');}));
}
<?php
# https://www.codewars.com/kata/58a369fa5b3daf464200006c How many e-mails we sent today?
function getPercentage(int $sent, int $limit = 1000): string {
if(0 == $sent) return "No e-mails sent";
if($sent >= $limit) return "Daily limit is reached";
return floor($sent*100/$limit)."%";
}

Just PHP FUN 054.

Started at 21:20 20.07.2020 July Monday.
Finised at 23:14 20.07.2020 July Monday. (1hrs 54minutes)

<?php
# https://www.codewars.com/kata/57ad85bb7cb1f3ae7c000039 Numbers with this digit inside.
function numbersWithDigitInside($x, $d) {
$ans = [];
for($i = 1; $i <= $x; $i += 1) if(false !== strpos(strval($i),strval($d))) array_push($ans,$i);
if(empty($ans)) return [0,0,0];
return [count($ans),array_sum($ans),array_product($ans)];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment