Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Implement @try_this decorator here )
- import queue
- import threading
- import time
- DATA = {
- 'name': 'MainCategory',
- 'values': [
- {
- 'name': 'Category1',
- 'values': [2, 5, 6]
- }, {
- 'name': 'Category2',
- 'values': [4, 7, 1]
- }, {
- 'name': 'Category3',
- 'values': [3, 2, 8]
- }
- ]
- }
- def calculate(data: dict) -> list:
- """
- Note: Each column in data represents a monthly sales for the category.
- This function calculates total sales for each month.
- """
- return [sum(col) for col in zip(*[row for row in [val['values'] for val in data['values']]])]
- if __name__ == '__main__':
- assert calculate(DATA) == [9, 14, 15]
Advertisement
Add Comment
Please, Sign In to add comment