Skip to content

Instantly share code, notes, and snippets.

@lbvf50mobile
Created July 2, 2020 15:29
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/76f654e75bcef8758c906ef9bf4e3bba to your computer and use it in GitHub Desktop.
Save lbvf50mobile/76f654e75bcef8758c906ef9bf4e3bba to your computer and use it in GitHub Desktop.
Just PHP FUN 039.
<?php
# https://www.codewars.com/kata/5a9e86705ee396d6be000091 Check three and two.
function checkThreeAndTwo($arr) {
$x = array_count_values($arr);
return 2 == count($x) && in_array(2,$x) && in_array(3,$x);
}
<?php
# https://www.codewars.com/kata/585b1fafe08bae9988000314 Digits explosion.
function digits_explode(string $s): string {
if(empty($s)) return '';
$ans = "";
foreach(str_split($s) as $v) $ans .= str_repeat($v,$v);
return $ans;
}

Just PHP FUN 039.

Started at 21:35 02.07.2020 Thursday July.
Finished at 22:26 02.07.2020 Thursday July. (0hrs 49minues)

<?php
# https://www.codewars.com/kata/58670300f04e7449290000e5 Thinkful - List Drills: Longest word.
function longest($words) {
return max(array_map('strlen',$words));
}
<?php
# https://www.codewars.com/kata/52e9aa89b5acdd26d3000127 Multiply characters.
function spam(int $n): string {
return str_repeat('hue',$n);
}
<?php
# https://www.codewars.com/kata/598f76a44f613e0e0b000026 Sum of integers in string.
function sum_of_integers_in_string(string $s): int {
$mtch = [];
preg_match_all('/\d+/',$s,$mtch);
return array_sum($mtch[0]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment