PHP,368字节
$str = "pa55 w0rd";
$str = str_replace(" ","_",$str);
$output AND $numStr = "";
$numArray = ['0','1','2','3','4','5','6','7','8','9'];
for($i=0;$i<strlen($str);$i++){
in_array($str[$i],$numArray)?($numStr = $numStr.$str[$i]):((rand(10,100)%2==0)?$str[$i] = strtoupper($str[$i]) AND $output = $output.$str[$i]:$output = $output.$str[$i]);
}
echo $output = $output.$numStr;
非高尔夫代码:
$str = "pa55 w0rd";
$str = str_replace(" ","_",$str);
$len = strlen($str);
$output = "";
$numStr = "";
$numArray = ['0','1','2','3','4','5','6','7','8','9'];
for($i=0;$i<$len;$i++){
if(in_array($str[$i],$numArray)){
$numStr = $numStr.$str[$i];
}else {
if(rand(10,100)%2==0)
{
$str[$i] = strtoupper($str[$i]);
}
$output = $output.$str[$i];
}
}
$output = $output.$numStr;
echo $output;