<?php
function checkCase($string)
{
$symMap = [
"." => ">",
"," => "<"
];
foreach($symMap as $k => $v)
$symMap[$v] = $k;
$element = str_split($string);
foreach($element as &$item)
{
if(in_array($item, $symMap))
$item = [$item, $symMap[$item]];
else
$item = [strtolower($item), strtoupper($item)];
}
$flags = array_fill(0, count($element), 0);
$result = [];
while(true)
{
$solution = "";
foreach(range(0, count($element) - 1) as $i)
{
$solution .= $element[$i][$flags[$i]];
}
$isEnding = function() use(&$flags, $element) {
foreach(range(0, count($flags) - 1) as $i)
{
if($flags[$i] < count($element[$i]) - 1)
{
$flags[$i]++;
if($i > 0)
foreach(range(0, $i - 1) as $j)
$flags[$j] = 0;
return false;
}
}
return true;
};
if(!$isEnding())
$result[] = $solution;
else
break;
}
return $result;
}
var_dump(checkCase("A.B"));
var_dump(checkCase("ABCD"));
- Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.7
- array(7) {
[0]=>
string(3) "a.b"
[1]=>
string(3) "A.b"
[2]=>
string(3) "a>b"
[3]=>
string(3) "A>b"
[4]=>
string(3) "a.B"
[5]=>
string(3) "A.B"
[6]=>
string(3) "a>B"
}
array(15) {
[0]=>
string(4) "abcd"
[1]=>
string(4) "Abcd"
[2]=>
string(4) "aBcd"
[3]=>
string(4) "ABcd"
[4]=>
string(4) "abCd"
[5]=>
string(4) "AbCd"
[6]=>
string(4) "aBCd"
[7]=>
string(4) "ABCd"
[8]=>
string(4) "abcD"
[9]=>
string(4) "AbcD"
[10]=>
string(4) "aBcD"
[11]=>
string(4) "ABcD"
[12]=>
string(4) "abCD"
[13]=>
string(4) "AbCD"
[14]=>
string(4) "aBCD"
}
- Output for 4.4.2 - 4.4.9, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29
- Parse error: syntax error, unexpected '[' in /in/9ZDMF on line 5
Process exited with code 255. - Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1, 5.0.0 - 5.0.5
- Parse error: parse error, unexpected '[' in /in/9ZDMF on line 5
Process exited with code 255. - Output for 4.3.2 - 4.3.4
- Parse error: parse error in /in/9ZDMF on line 5
Process exited with code 255.
preferences:
241.72 ms | 401 KiB | 384 Q