here's my php, which is basically the same as Chris' solution:

<?
$fp = fopen ($argv[1],"r");
while($line=fgets($fp,4092))
{
 $numbersArray = split(" ",$line);
 $output="match";
 $size=count($numbersArray);
 for ($i=0;$i<($size-1);$i++)
   {
     $difference = abs($numbersArray[$i]-$numbersArray[$i+1]);
     if ($difference>($size-1)||!$difference)
       {
         $output = "not a match";
         break;
       }
   }
 echo $output."\n";
}
fclose($fp);
?>


On 11/1/06, Paul Seamons <[EMAIL PROTECTED]> wrote:

Need to catch the following:

>  if ($diff > $size) {

   if ($diff && $diff > $size) {

Because the difference must be in the range 1 .. n - 1

Paul Seamons

PS - unmaintainable solution in perl
perl -ne 'chop;@a=split;$n=grep{$t=abs($a[$_]-$a[$_-1]);!$t||$t>[EMAIL 
PROTECTED]
$#a;print$n?"not a ":"","match\n"'

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




--
http://www.ryanbyrd.net

/*
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