command-line php solution

if (!file_exists($argv[1])) exit;
[EMAIL PROTECTED]($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");
        }
}

/*
PLUG: http://plug.org, #utah on irc.freenode.net
Unsubscribe: http://plug.org/mailman/options/plug
Don't fear the penguin.
*/

Reply via email to