Git Product home page Git Product logo

batch4-challenge's Introduction

Coding Challenge

This is a coding challenge for avion school batch #5 given by Sir Adrian.

Background

A bakery used to base the price of their produce on an individual item cost. So if a customer ordered 10 cross buns then they would be charged 10x the cost of single bun. The bakery has decided to start selling their produce prepackaged in bunches and charging the customer on a per pack basis. So if the shop sold vegemite scroll in packs of 3 and 5 and a customer ordered 8 they would get a pack of 3 and a pack of 5. The bakery currently sells the following products:

Name Code Packs
Vegemite Scroll VS5 3 @ $6.99
5 @ $8.99
Blueberry Muffin MB11 2 @ $9.95
5 @ $16.95
8 @ $24.95
Croissant CF 3 @ $5.95
5 @ $9.95
9 @ $16.99

Task

Given a customer order you are required to determine the cost and pack breakdown for each product. To save on shipping space each order should contain the minimal number of packs.

Input

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

10 VS5
14 MB11
13 CF

Output

A successfully passing test(s) that demonstrates the following output:

10 VS5 $17.98
    2 x 5 $8.99
14 MB11 $54.8
    1 x 8 $24.95
    3 x 2 $9.95
13 CF $25.85
    2 x 5 $9.95
    1 x 3 $5.95

Advise

  • The input/output format is not important, do whatever feels reasonable
  • Make sure you include at least one test
  • We expect the see code which you would be happy to put in production
  • If something is not clear don’t hesitate to ask or just make an assumption and go with it

Installation

Use bundler to install the dependencies. To do so, you need to install the bundler gem if you haven't already done so

gem install bundler

Run bundler

bundle

Run

Execute the runner.rb file, run with:

ruby bin/runner.rb

Test

How to run the test suite:

rspec spec

batch4-challenge's People

Contributors

youngestbllnr avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.