Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions java/logic-2/makeBricks.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,20 @@
* of small bricks (1 inch each) and big bricks (5 inches each). Return true
* if it is possible to make the goal by choosing from the given bricks.
*/
public boolean makeBricks(int small, int big, int goal) {
int remainder = goal >= (5 * big) ? goal - (5 * big) : goal % 5;

return small >= remainder;
public int loneSum(int a, int b, int c) {
if (a == b && b == c && a == c) {
return 0;
}
else if (a == b) {
return c;
}
else if (b == c) {
return a;
}
else if (a == c) {
return b;
}
else {
return a + b + c;
}
}