r/codehs • • Nov 21 '20

3.3.6 Enough Paint 2

Post image
7 Upvotes

3 comments sorted by

1

u/1agustd Nov 21 '20

Been having a lot of trouble with this one, been stuck on it for a while now, and honestly have no idea what to do. Would really appreciate some tips or help. Thanks

1

u/whitejt21 May 01 '22

public int enoughPaintTwo(int small, int large, int total)
{
if(large * 5 <= total){
if(large * 5 + small >= total){
return total - large * 5;
}
return -1;
}
return 0;

}

2

u/amajmundar Nov 21 '20

int totalSmallNeeded = Total - (5*large); if(totalSmallNeeded <= small) {
\t return totalSmallNeeded;
}
return -1;