Submit | All submissions | Best solutions | Back to list |
COOLIT - Conta gli oggetti vecchi |
We need to update the inventory of a supermarket by deleting all products that have a validity date before 2018. Each product in the inventory is saved as a dictionary formed by the fields: code, name, price and valid. The inventory is saved as a list containing a set of products. Your task is to read the old inventory and count the number of items that are expired, i.e. the number of products that have a validity of less than 2018. If the inventory is empty, 0 should be returned.
Input
A list of products (dictionaries) where each product is composed of 4 keys: 'code', 'name', 'price' and 'valid'. The list can be empty.
Output
The number of products whose 'valid' field is less than 2018.
Example
Input: [{'code':'1234', 'name' : 'biscotti', 'price' : 3, 'valid' : 2019},{'code':'2345', 'name' : 'pasta', 'price' : 2, 'valid' : 2017},{'code':'6788', 'name' : 'marmellata', 'price' : 4, 'valid' : 2018}] Output: 1
Added by: | giorgio.piccardo |
Date: | 2018-05-04 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | NCSHARP JULIA PYPY3 PYTHON3 |