Developer challenge

Wally’s Widget Company is a widget wholesaler. They sell widgets in a variety of pack sizes:

  • 250 Widgets
  • 500 Widgets
  • 1000 Widgets
  • 2000 Widgets
  • 5000 Widgets


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:

  1. Only whole packs can be sent. Packs cannot be broken open.
  2. Within the constraints of Rule 1 above, send out no more widgets than necessary to fulfil the order.
  3. Within the constraints of Rules 1 & 2 above, send out as few packs as possible to fulfil each order.


So, for example:

Number of Widgets orderedCorrect packs to sendIncorrect solution(s)
1250 x 1500 x 1 (too many widgets)
250250 x 1500 x 1 (too many widgets)
251500 x 1250 x 2 (too many packs)
501500 x 1 + 250 x 11,000 x 1 (too many widgets)
12,0015,000 x 2 + 2,000 x 1 + 250 x 1250 x 3 (too many packs), 5,000 x 3 (too many widgets)

Your task


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.