Skip to content

Instantly share code, notes, and snippets.

@lbvf50mobile
Last active August 14, 2020 16:01
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/04bea31ce5969eeff0eb2288b49c425f to your computer and use it in GitHub Desktop.
Save lbvf50mobile/04bea31ce5969eeff0eb2288b49c425f to your computer and use it in GitHub Desktop.
Just PHP FUN 076.
<?php
# https://www.codewars.com/kata/56dbe7f113c2f63570000b86 Moves in squared strings (II).
function rot($s) {
$x = array_reverse(explode("\n",$s));
$x = array_map('strrev',$x);
return implode("\n",$x);
}
function selfieAndRot($s) {
$x = explode("\n",$s);
$x1 = array_reverse(explode("\n",$s));
$x1 = array_map('strrev',$x1);
$dots = str_repeat(".",count($x1));
$x = array_map(function($s) use ($dots){ return $s.$dots;}, $x);
$x1 = array_map(function($s) use ($dots){ return $dots.$s;}, $x1);
return implode("\n",array_merge($x,$x1));
}
function oper($fct, $s) {
return call_user_func ($fct,$s);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment