Course of Raku / Addendum 🆕 / Working with data / Lists, arrays, and hashes / Exercises
Merge two inventories
Problem
Two shops keep their stock in hashes:
apples => 3, pears => 2 and
apples => 4, plums => 5. Combine them into one,
adding the quantities for keys that appear in both. Print the result
sorted by key, as key: total pairs joined with commas.
Example
The program prints:
apples: 7, pears: 2, plums: 5Solution
Course navigation
← Solution: Split into even and odd | Solution: Merge two inventories →