Sequence Safety checker, %=not monotonic, ! = difference too big or small, ~~~~ = safe
~~~~
~!
~~!
~%
~~%
~~~~
Sequence Safety checker, %=not monotonic, ! = difference too big or small, ~~~~ = safe<?php $list = [
[7,6,4,2,1],
[1,2,7,8,9],
[9,7,6,2,1],
[1,3,2,4,5],
[8,6,4,4,1],
[1,3,6,7,9]];


foreach($list as $l){echo'<br>';
for($i=1;$i<5;$i++){
if($i==1){unset($osq);}
$seq=$l[$i-1]<=>$l[$i];
if(isset($osq)&&$osq!=$seq){echo '%';break;}
$diff=abs($l[$i-1]-$l[$i]);
if($diff>=1&&$diff<=3){echo'~';}
else{echo '!';break;}
$osq=$seq;
}
}
show_source('a2.php');