Please complete the following exercise. Don't read ahead. At each stage build the simplest implementation which meets the requirement. Rather than looking stuff up, feel free to ask your partner for help.
You are building a checkout system for a shop which only sells apples and oranges.
Apples cost 60p and oranges cost 25p.
Build a checkout system which takes a list of items scanned at the till and outputs the total cost
For example: [ Apple, Apple, Orange, Apple ] => £2.05
Make reasonable assumptions about the inputs to your solution; for example, many candidates take a list of strings as input
The shop decides to introduce two new offers
Buy one, get one free on Apples
3 for the price of 2 on Oranges
Update your checkout functions accordingly
The shop adds Bananas which cost 20p
Bananas are added to the same buy one, get one free offer as apples
The cheapest item should be given free first
Update your checkout
The shop adds melons which cost £1
Melons are available through a separate 3 for 2 offer
Update your checkout
Customers complain that they do not know how much their shopping costs until all produce are scanned
Re-implement your checkout to show a running total as items are scanned.
Customers notice that they could save money by making multiple trips to the checkout. Why?
Update the checkout so that customers get the lower price for only one trip