Was bored so decided to optimize my solution a little bit more.
You can find the original solution here.
$file_content = explode("\n",(fread(fopen("input.txt",'r'), filesize("input.txt")));
$output = fopen("output.txt", 'w');
$hacker = array('h','a','c','k','e','r','u','p');
for ($j = 1; $j <= intval($file_content[0]); $j++){
for ($zzz = 0; $zzz < count($hacker); $zzz++){
$freq[$hacker[$zzz]] = 0;
}
$word = strtolower(str_replace(" ","",$file_content[$j]));
$len = strlen($word);
for ($i=0; $i<$len; $i++) {
$letter = $word[$i];
if (in_array($letter,$hacker)){
if ($letter =="c") {$freq[$letter] += 0.5;}
else {$freq[$letter]++;}
}
}
$stringData = "Case #" . $j . ": " . intval(min($freq)) . "\n";
fwrite($output, $stringData);
}
fclose($output);

Pingback: [Solution] Facebook Hacker Cup 2012 – Qualifying round – Alphabet Soup | just another blog page . . .