Skip to content

Instantly share code, notes, and snippets.

@notbrain
Created September 10, 2011 16:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save notbrain/1208514 to your computer and use it in GitHub Desktop.
Save notbrain/1208514 to your computer and use it in GitHub Desktop.
Function to return whether or not one 'design' array 'fits' into another 'max'
// Currently incomplete implementation!
private Boolean designFits(int[] max, int[] design) {
Boolean designFits = true;
Arrays.sort(max);
Arrays.sort(design);
int passCount = 0;
if(design.length <= max.length) {
for(int i = 0; i < max.length; i++) {
for(int j = 0; j < design.length; j++) {
if(max[i] <= design[j]) {
passCount++;
}
}
}
if(passCount == 0 || passCount > max.length) {
designFits = false;
}
} else {
designFits = false;
}
return designFits;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment