Skip to content

Instantly share code, notes, and snippets.

@aponsin
Forked from gottfrois/checkout.md
Last active June 5, 2017 02:09
Show Gist options
  • Star 12 You must be signed in to star a gist
  • Fork 10 You must be signed in to fork a gist
  • Save aponsin/3fcc41e5e538dbb86947 to your computer and use it in GitHub Desktop.
Save aponsin/3fcc41e5e538dbb86947 to your computer and use it in GitHub Desktop.
Welcome to TextMaster's recruitment. This is a simple coding exercise used by TextMaster for technical recruitment purposes. There are no limit of time to perform this task nor any particular restriction, however considering the rather simple nature of the test we will expect a reasonable delivery time.

Please send a zip archive containing your code and any relevant materials in an email along with your resume and motivations to jobs+ror@textmaster.com, please add tech-test@textmaster.com in CC. The purpose of this test is to verify your abilities to code and see how you architecture an application, so this is the time to show everything you know that is applicable and relevant (design pattern, OOP concepts, etc.) Finally, please note that even if you have questions about the test we will not answer them, do what you think is best.

TextMaster's quest for global domination has prompted us to open a supermarket - we sell only three products:

+--------------|--------------|---------+
| Product Code |     Name     |  Price  |
+--------------|--------------|---------+
|     FR1      |   Fruit tea  |  $3.11  |
|     AP1      |   Apple      |  $5.00  |
|     CF1      |   Coffee     | $11.23  |
+--------------|--------------|---------+

Our CEO is a big fan of buy-one-get-one-free offers and of fruit tea. He wants us to add a rule to do this.

The COO, though, likes low prices and wants people buying apple to get a price discount for bulk purchases. If you buy 3 or more apple, the price should drop to $4.50. Our check-out can scan items in any order, and because the CEO and COO change their minds often, it needs to be flexible regarding our pricing rules.

The interface to our checkout looks like this (shown in Ruby):

co = Checkout.new(pricing_rules)
co.scan(item)
co.scan(item)
price = co.total

Implement a checkout system that fulfils these requirements in Ruby.

Here are some test data:

Basket: FR1, AP1, FR1, CF1
Total price expected: $22.25
Basket: FR1, FR1
Total price expected: $3.11
Basket: AP1, AP1, FR1, AP1
Total price expected: $16.61

PS: Here at TextMaster, we love specs ;)

@shawnpk
Copy link

shawnpk commented Feb 24, 2016

I think the price for the first basket is incorrect. If it's BOGO on fruit tea, the price should be $19.34. If it's not BOGO, the price should be $22.45.

@eomuraliev
Copy link

I agree, the first basket FR1, AP1, FR1, CF1 should be priced at $19.34, in the order entered the sum would be 3.11 + 5.00 + 0 + 11.23.

@noahmatisoff
Copy link

+1 ^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment