Find the value in the minimum number of trials
<p>I have an array of 52 different values that I can pass through a class to get a number in return.</p>

<pre><code>$array = array("A","B","C","D"...);
</code></pre>

<p>Each value passed through the class gives a different number that can be either positive or negative.
The numbers are not equally distributed but are sorted in natural order.</p>

<p>E.g.</p>

<pre><code>$myclass-&gt;calculate("A"); // 2.3
$myclass-&gt;calculate("B"); // 0.25
$myclass-&gt;calculate("C"); // -1.3
$myclass-&gt;calculate("D"); // -6
</code></pre>

<p>I want to get the last value that return a number >= 0.20 (in the example would be "B").</p>

<p>This should be done in the minimum number of "class invocation" to avoid time wasting.</p>

<p>I thought something like: divide $array in 2 pieces and calculate the number I get, if it is >= 20, then split the last part of $array in other 2 smaller pieces and so on. But I don't know if this would work.</p>

<p>How would you solve this?</p>

<p>Thanks in advance.</p>
