mozy contest: problem 6 PHP solution
Nicholas Leippe
nick at leippe.com
Mon Nov 6 10:03:36 MST 2006
The 6th problem was to simply rot1 all alphabet characters in the input.
<?
while ($line = fgets(STDIN)) {
$line = trim($line);
for ($i = 0; $i < strlen($line); $i++) {
$c = $line{$i};
if ($c == ' ') {
echo $c;
continue;
}
if (strtolower($c) == $c) {
$base = 'a';
} else {
$base = 'A';
}
echo chr(((ord($c) - ord($base) + 1) % 26) + ord($base));
}
echo "\n";
}
More information about the PLUG
mailing list