Skip to content

Commit 496292a

Browse files
author
Alfredo Miranda
committed
Minor change to makeChocolate.java
1 parent 6cce8a4 commit 496292a

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

java/logic-2/makeChocolate.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@
44
* can't be done.
55
*/
66
public int makeChocolate(int small, int big, int goal) {
7-
int count = 5 * big > goal ? goal - (goal % 5) : 5 * big;
8-
9-
if(goal - count <= small)
10-
return goal - count;
11-
12-
return -1;
7+
int remainder = goal >= 5 * big ? goal - (5 * big) : goal % 5;
8+
9+
return remainder <= small ? remainder : -1;
1310
}

0 commit comments

Comments
 (0)