Created
December 19, 2016 00:03
-
-
Save andreybleme/6dd246ba3700b7be5dd4d3875932236b to your computer and use it in GitHub Desktop.
This file contains 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
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