
- By Emmanuel Valverde
- ·
- Posted Jan 28, 2023 9:00:00 AM
Shopping cart
What do we want to build? We are building a shopping cart for an online grocery shop. The idea of this kata is to build the product in an iterative..
When Durance left his home to start his adventures, all he brought was a backpack. He eventually found more smaller bags to stash his items.
After enchanting his weapons and looking for ingredients and materials for a long time, Durance noticed his bags were really disorganized, maybe we can code a spell for him to organize them?
Create an application that helps Durance organize the items in his bags. Each bag can have either a category or not, the backpack has no category.
Items are always added to the backpack, if it happens to be full, the item is added to the next available bag.
After organizing the items, each bag should have the items belonging to its category, sorted alphabetically. If the bag happens to be full, the rest of the items are stored in the backpack or successive bags, following the previous sort.
Let's say that Durance has 8 items in his backpack and 1 empty extra bag, which has a category for `Metals`: backpack = ['Leather', 'Iron', 'Copper', 'Marigold', 'Wool', 'Gold', 'Silk', 'Copper']
bag_with_metals_category = []
bag_with_no_category = []
bag_with_weapons_category = []
bag_with_no_category = []
he finds 2 new items, which are stored in the next available bag, since the backpack is already full: backpack = ['Leather', 'Iron', 'Copper', 'Marigold', 'Wool', 'Gold', 'Silk', 'Copper']
bag_with_metals_category = ['Copper', 'Cherry Blossom']
bag_with_no_category = []
bag_with_weapons_category = []
bag_with_no_category = []
he now casts the organizing spell: backpack = ['Cherry Blossom', 'Iron', 'Leather', 'Marigold', 'Silk', 'Wool']
bag_with_metals_category = ['Copper', 'Copper', 'Copper', 'Gold']
bag_with_no_category = []
bag_with_weapons_category = []
bag_with_no_category = []
{
"clothes": ["Leather", "Linen", "Silk", "Wool"],
"herbs": ["Cherry Blossom", "Marigold", "Rose", "Seaweed"],
"metals": ["Copper", "Gold", "Iron", "Silver"],
"weapons": ["Axe", "Dagger", "Mace", "Sword"]
}
What do we want to build? We are building a shopping cart for an online grocery shop. The idea of this kata is to build the product in an iterative..
Iteration 1 Business rules We want to build an ATM machine and the first thing we need to do, is to create the software that will breakdown which..
In computer science, a stack is a famous abstract data type that provides certain operations on a collection of elements. Stacks have a long history,..
Join our newsletter for expert tips and inspirational case studies
Your welcome email is on its way! You can pick the emails you’d like to receive by clicking the link to the Preference Centre.
Join our newsletter for expert tips and inspirational case studies
Your welcome email is on its way! You can pick the emails you’d like to receive by clicking the link to the Preference Centre.