$10K coding deathmatch

Chris Carey chris.carey at gmail.com
Wed Nov 1 13:49:16 MST 2006


command-line php solution

if (!file_exists($argv[1])) exit;
$input=@file($argv[1]);

foreach($input as $line) {
	$numbers = split(" ",$line);
	$size = count($numbers);
	for($i=0;$i<$size;$i++) {
		$curr = $numbers[$i];
		if ($last) {
			$diff = abs($last - $curr);
			if ($diff > $size) {
				printf("not a match\n");
				break;
			}
		}
		$last = $curr;
		if ($size - 1 == $i) printf("match\n");
	}
}



More information about the PLUG mailing list