<?php // I rename this to makeindex.php_txt, edit it,
      // then create the actual .html file like this:
      //     php makeindex.php_txt >index.html
?>
<HTML>
<HEAD>
<TITLE>Binary Search Test Cases</TITLE>
</HEAD>
<BODY>

<h3>Test file for binary search functions</h3>

Each test looks something like this:

<pre>
Problem 1
3
in [
1
2
4
]? no
</pre>

Of lines 1 through 5+n of a given test,<br>
Each line is in Unix style, ended with newline ( '\x0A' ).<br>
Line 1 is the name of the problem. <br>
Line 2 is a signed integer, T <br>
Line 3 is the string <code>"in ["</code><br>
Line 4+i, where 0 <= i < n, is A[ i ], an int. <br>
Line 4+n is either <code>"]? yes"</code>  or <code> "]? no"</code><ul>
   <li>If yes, if r = your_binsearch( A, T ), test that<ul>
       <li>r != FAIL and </li>
       <li>A[r] == T. </li>
       </ul>
   <li>If no, test that r == FAIL. </li>
   </ul>
Line 5+n is a blank line. <br>
<p>

There are 4096 tests, with arrays ranging up to about 512 elements,
although the average is about 16 elements.  The correct answer is "yes"
in about half of the examples.  Unzipped, tests.txt is 680k.
<p>

<?php

$cmt = array(
"tests.txt.gz" => "the test data, gzipped",
"tests.zip" => "the test data, zipped",
"write_tests.py_txt" => "Python that generates the test file.",
"follow_tests.py_txt" => "Python to run the tests, includes binary_search."
);

$subst_url = array(
);

echo "<table>\n";
exec( "/bin/ls -ld *_tests.py_txt *.gz *.zip", $lines );
foreach( $lines as $line ) {
   echo "<tr>\n";
   $parts=explode( " ", $line );
   foreach( $parts as $path ) {
   } ; // Empty loop leaves path as last part
   $pieces=explode( "/", $path );
   foreach( $pieces as $file ) {
   } ; // Empty loop leaves file as last part
   $size=ceil( filesize($file) / 1024 );
   echo '<td valign="top">';
   if( isset( $subst_url[$file] ) )  $url = $subst_url[ $file ];
   else                              $url = $file;
   if( $line[0]=="d" ) {
      echo "<code><a href=\"$url/index.html\"\n>$file/</a></code>";
   } else {
      echo "<code><a href=\"$url\"\n>$file</a> (${size}K)</code>";
   }
   echo "</td>\n";
   if( isset( $cmt[$file] ) ) {
     echo "<td><font size=\"-1\">$cmt[$file]</font></td>\n";
   }
   echo "</tr>\n\n";
}
echo "</table>\n";
?>
<p>
(The php and py scripts are named *.php_txt and *.py_txt
so my web host doesn't confuse them with CGI scripts.)
<p>

<font size="-1">
This page was made with a
<a href="makeindex.php_txt">php script</a>.
Last change <?php
    date_default_timezone_set('America/New_York');
    echo date("Y-m-d H:i:s T", filemtime( "datefile" )) ?><br>

--<a href="mailto:sw_at_tiac_remove-this_dot_net">Steve Witham</a>
Up to my <a href="http://www.mac-guyver.com/switham">home page</a>.

</BODY>
</HTML>
