Skip to content

Instantly share code, notes, and snippets.

@lbvf50mobile
Last active June 22, 2020 15:13
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/4d6f2ab1c0952605f982de02752f179c to your computer and use it in GitHub Desktop.
Save lbvf50mobile/4d6f2ab1c0952605f982de02752f179c to your computer and use it in GitHub Desktop.
Just PHP FUN 030.
<?php
# https://www.codewars.com/kata/57fd696e26b06857eb0011e7 Hungarian Vowel Harmony (easy).
function dative(string $w): string {
$tmp = preg_replace('/[^eéiíöőüűaáoóuú]/',"",$w);
if(preg_match('/[aáoóuú]$/',$tmp)) return "${w}nak";
return "${w}nek";
}
<?php
# https://www.codewars.com/kata/58485a43d750d23bad0000e6 Fizz Buzz Cuckoo Clock.
function fizzBuzzCuckooClock($time) {
if("00:00" == $time || "12:00" == $time) return "Cuckoo Cuckoo Cuckoo Cuckoo Cuckoo Cuckoo Cuckoo Cuckoo Cuckoo Cuckoo Cuckoo Cuckoo";
list($hrs,$min) = explode(":",$time);
if( 0 == $min) return "Cuckoo Cuckoo Cuckoo Cuckoo Cuckoo Cuckoo Cuckoo Cuckoo Cuckoo";
if( 30 == $min) return "Cuckoo";
if( 0 == $min%15) return "Fizz Buzz";
if( 0 == $min%3 ) return "Fizz";
if( 0 == $min % 5) return "Buzz";
return "tick";
}

Just PHP FUN 030.

Started at 22.06.2020 20:18 Monday.
Finished at 22.06.2020 22:13 Monday. (1hr 55minutes)

<?php
# https://www.codewars.com/kata/57f604a21bd4fe771b00009c The Office IV - Find a Meeting Room.
function meeting($a) {
$x = array_search("O",$a);
if(false === $x) return "None available!";
return $x;
}
<?php
# https://www.codewars.com/kata/5663f5305102699bad000056 Maximum Length Difference.
function mxdiflg($a1, $a2) {
$a1 = array_map('strlen',$a1); $a2 = array_map('strlen',$a2);
if(empty($a1) || empty($a2)) return -1;
return max( abs(max($a1)-min($a2)), abs(max($a2)-min($a1)));
}
<?php
# https://www.codewars.com/kata/5b3e1dca3da310a4390000f3 Offload your work!
function workNeeded($projectMinutes, $freelancers) {
$off = array_reduce($freelancers,function($acc,$x){ return $acc + $x[1] + $x[0]*60;});
$time = $projectMinutes - $off;
if( $time <= 0) return "Easy Money!";
$min = $time%60; $hrs = floor($time/60);
return "I need to work $hrs hour(s) and $min minute(s)";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment