- https://www.codewars.com/kata/581e014b55f2c52bb00000f8 Decipher this!
Started at 22:47 21.10.2020 Wednesday Oct.
Finished at
<?php | |
# https://www.codewars.com/kata/581e014b55f2c52bb00000f8 Decipher this! | |
function decipherThis($str){ | |
return preg_replace_callback('/\w+/',function($x){ | |
$w = $x[0]; | |
$w1 = digitized_to_str($w); | |
$w2 = swapper($w1); | |
return $w2; | |
},$str); | |
} | |
function digitized_to_str($str){ | |
return preg_replace_callback('/[0-9]+/',function($x){ return chr(intval($x[0]));},$str); | |
} | |
function swapper($str){ | |
if( 3 > strlen($str)) return $str; | |
$a = str_split($str); | |
$l = $a[strlen($str)-1]; | |
$f = $a[1]; | |
$a[1] = $l; $a[strlen($str)-1] = $f; | |
return implode($a); | |
} |
Started at 22:47 21.10.2020 Wednesday Oct.
Finished at