title: Find the Minimum Positive Value
body: <p>What's the best algorithm to find the smallest non zero positive value from a fixed number (in this case 3) of values or return 0 if there are no positive questions?</p>
  
  <p>My naive approach is below (in Delphi, but feel free to use whatever you like), but I think there's a more elegant way.</p>
  
  <pre><code>value1Temp := MaxInt;
  value2Temp := MaxInt;
  value3Temp := MaxInt;
  
  if ( value1T &gt; 0) then
    value1Temp := value1;
  if ( value2 &gt; 0) then
    value2Temp := value2;
  if ( value3 &gt; 0) then
    value3Temp  := value3;
  
  Result := Min(value1Temp, Min(value2Temp, value3Temp));
  if Result = MaxInt then
    Result := 0;
  </code></pre>
  
  <p><strong>Edit:</strong> Sorry added what's needed if there are no positive numbers. I thought I had it in there before, but must have missed it.</p>