Skip to content

Instantly share code, notes, and snippets.

@andreybleme
Created December 19, 2016 00:03
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 andreybleme/6dd246ba3700b7be5dd4d3875932236b to your computer and use it in GitHub Desktop.
Save andreybleme/6dd246ba3700b7be5dd4d3875932236b to your computer and use it in GitHub Desktop.
public class Boxes {
public static int minimalNumberOfBoxes(int products, int availableLargeBoxes, int availableSmallBoxes) {
int smallBoxes = products % (availableLargeBoxes * 5);
int bigBoxes = products - (smallBoxes * 5);
if (((availableLargeBoxes * 5) + availableSmallBoxes) < products) {
return -1;
}
return (bigBoxes + smallBoxes) * -1;
}
public static void main(String[] args) {
System.out.println(minimalNumberOfBoxes(16, 2, 10));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment