-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFlourPacker.java
More file actions
26 lines (26 loc) · 767 Bytes
/
Copy pathFlourPacker.java
File metadata and controls
26 lines (26 loc) · 767 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
public class FlourPacker {
public static boolean canPack(int bigCount, int smallCount, int goal){
if(bigCount < 0 | smallCount < 0 | goal < 0 ) {
return false;
}
if(goal == ((bigCount)*5 + smallCount)){
return true;
}
else if (goal <= ((bigCount)*5 + smallCount)){
if (bigCount == 0){
return true;
}
for(int i = 1; i <= bigCount; i++){
if(goal == i*5){
return true;
}
for(int j=1;j<=smallCount;j++){
if(goal==((i*5)+(j*1))){
return true;
}
}
}
}
return false;
}
}