DEV Community

Paolo Ventura
Paolo Ventura

Posted on • Edited on

100 algos in 100 days (Day 6)

Code Dojo

I attended a code dojo with Fox presenting on Elephant Carpaccio. Essentially vertically slicing tasks which leads to a much more efficient outcome. I will definitely use this to slice my approach for Algo problems in the future.

Here is my slicing of the supermarket basket calculator (with tax):

Our slices:

  • (Spike) Calculate %s in JS. Rounding errors. Financial Calculations

  • Scoping the project, UI considerations. Who are the stakeholders

  • Define outliers / requirements negative prices allowed? Non Valid state codes? Other deals BOGOF? Free samples 0 price

  • Write some tests with example baskets of 1 item

  • Implement Gross Price of Order (MVP) which returns => units*price


    • Implement tests for outliers

  • Implement Bulk Buy Discount Total using below table => calculateDiscount(calculateGrossPrice)*calculateGrossPrice


Order value Discount rate
$1,000 3%
$5,000 5%
$7,000 7%
$10,000 10%
$50,000 15%

My q: Are the discounts included like tax , incrementally? No

  • Include State Tax

  • Include the discounts and calculate Final NET Calculated Price (Total - Discounts)

State Tax rate
UT 6.85%
NV 8.00%
TX 6.25%
AL 4.00%
CA 8.25%

Note: We were meant to implement tax first - next time!

Top comments (0)