Simple 'Make chocolate' logic and solution review
<p>I am working on a coding Bat question <a href="http://codingbat.com/prob/p191363" rel="nofollow noreferrer">http://codingbat.com/prob/p191363</a> which has already many solutions here <a href="https://stackoverflow.com/questions/15617869/condingbat-python-puzzle-results-in-timed-out">CondingBat Python puzzle results in &quot;Timed out&quot;</a>. </p>

<p><strong>My solution is marked as partially right. Trying to understand the problem.</strong></p>

<blockquote>
  <p>We want make a package of goal kilos of chocolate. We have small bars 
  (1 kilo each) and big bars (5 kilos each). Return the number of small 
  bars to use, assuming we always use big bars before small bars. Return
  -1 if it can't be done.</p>
  
  <p>makeChocolate(4, 1, 9) → 4 makeChocolate(4, 1, 10) → -1<br>
  makeChocolate(4, 1, 7) → 2</p>
</blockquote>

<p>From what I understand, make chocolates method should use all available big bars to reach goal and then use small bars. Am returning 0 if big bars are already enough. <em>Can somebody please tell me If am understanding the problem incorrectly ?</em></p>

<p><strong>Here is my solution</strong> : </p>

<pre><code>public int makeChocolate(int small, int big, int goal) {
    if (small + big*5 &lt; goal)  return -1;

    int smallNeeded = goal - big * 5;

    if(smallNeeded &lt;= 0) return 0;

    return smallNeeded;
}
</code></pre>