Skip to content

Instantly share code, notes, and snippets.

@ben-gy
Created February 10, 2016 07:05
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 ben-gy/633bacb1be7255b217a5 to your computer and use it in GitHub Desktop.
Save ben-gy/633bacb1be7255b217a5 to your computer and use it in GitHub Desktop.
Programming challenge freighter ship
You have been hired by a late 18th century naval shipping company who transport large quantities of gold.
They company has multiple ships, all capable of carry different amounts of gold.
The current shipping coordinator, known only as the Seawolf, has realised that their current shipping methods are inefficient and wishes to have a system to reduce the required trips for a given weight of gold.
Your task is to create a system that for a given set of ships, can transport a quantity of gold with the fewest possible trips. Each ship may only carry it's exact quantity. The company has multiple of each ship class.
For instance, with the following ship classes:
Speedy‍ - 1 Tonne capacity.
El Gamo - 6 Tonne capacity.
Esmeralda - 8 Tonne capacity.
Expected Results:
Commissioned to transport 8 Tonne of gold. 1 Esmeralda.
Commissioned to transport 14 Tonne of gold. 1 Esmeralda, 1 El Gamo.
Commissioned to transport 12 Tonne of gold. 2 El Gamo's.
The company is looking to expand into other ships very soon, your solution should take this into account. Your solution should be in Ruby, you can prove your solution any way you choose.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment