Wally’s Widget Company is a widget wholesaler. They sell widgets in a variety of pack sizes:
Their customers can order any number of widgets, but they will always be given complete packs. The company wants to be able to fulfil all orders according to the following rules:
So, for example:
Number of Widgets ordered | Correct packs to send | Incorrect solution(s) |
---|---|---|
1 | 250 x 1 | 500 x 1 (too many widgets) |
250 | 250 x 1 | 500 x 1 (too many widgets) |
251 | 500 x 1 | 250 x 2 (too many packs) |
501 | 500 x 1 + 250 x 1 | 1,000 x 1 (too many widgets) |
12,001 | 5,000 x 2 + 2,000 x 1 + 250 x 1 | 250 x 3 (too many packs), 5,000 x 3 (too many widgets) |
Write a program that will tell Wally’s Widgets what packs to send out, for any given order size.
Keep your program flexible, so that new pack sizes may be added, or existing pack sizes changed or discarded, at a later date with minimal adjustments to your program. Be sure to test that the rules stillwork as intended with a different pack configuration!
Use JavaScript, or an alternative solution of your choice suitable for deployment to an online browser-based tool. We are mainly interested in your algorithmic problem solving and development approach, however strong demonstration of a framework such as Laravel and a web based user interface is appreciated if time allows. Please send us your code (either on GitHub, or send us the files), and also deploy your solution to an online environment that we can access via the web.