Warehouse bay inventory

Write codeEasy14 min

Your task

A warehouse aisle is recorded as a rectangular grid. Each row is a shelf level read from top to bottom, and each column is a bay. shelf_map[level][bay] holds the carton count sitting on that level of that bay, or -1 when that level is sealed for an inventory audit and cannot be counted. Return one number per bay, left to right: the total cartons across that bay's unsealed levels. A bay whose levels are all sealed reports -1 instead of a total, because 0 is a real answer for a bay that is simply open and empty. An aisle with no levels, or levels with no bays, returns an empty list.

Examples

bay_load_totals(shelf_map: list[list[int]]) -> list[int]
Example 1
Inputbay_load_totals([[3, -1, 0], [2, 4, 0], [1, -1, 5]])
Output[6, 4, 5]
Example 2
Inputbay_load_totals([[-1, 7], [-1, 0]])
Output[-1, 7]
Example 3
Inputbay_load_totals([[0, 0]])
Output[0, 0]