Skip to content

chui-mel/bundle-calculator

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bundle Calculator

Context

Social media Influencers have been basing the price of their social media post on a single post basis. So If a brand required 10 posts (for example spread over a period) then they would be charged 10x the cost of a single post. TRIBE has decided to allow social media influencers to sell posts in bundles and charge the brand on a per bundle basis. So if the Influencer sold image based posts in bundles of 5 and 10 and brand ordered 15 they would get a bundle of 10 and a bundle of 5.

TRIBE currently allows the influencer to monitise the following submission formats:

Submission format Format code Bundles
Image IMG 5 @ $450 10 @ $800
Audio Flac 3 @ $427.50 6 @ $810 9 @ $1147.50
Video VID 3 @ $570 5 @ $900 9 @ $1530

Task

Given a brands order, you are required to determine the cost and bundle breakdown for each submission format. For simplicity, each order should contain the minimal number of bundles.

Input:

Each order has a series of lines with each line containing the number of items followed by the submission format code An example input:

10 IMG
15 FLAC
13 VID

Output:

A successfully passing test(s) that demonstrates the following output: (The format of the output is not important)

10 IMG $800
  1 x 10 $800
15 FLAC $1957.50
  1 x 9 $1147.50
  1 x 6 $810
13 VID $2370
  2 x 5 $1800
  1 x 3 $570

How to run

Ruby 2.4.1 is required. Before running, run bundle install.

  1. rake quality to do static check for code.
  2. rake spec to run all unittest.
  3. create a order file and you can refer to test_order.
  4. run ruby app/bundle_calculator.rb test_order to see the result.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 100.0%