Created
September 10, 2011 16:53
-
-
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'
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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