Storage Unit Allocation

Problem Statement

Company ABC receives N containers with raw materials. The company wants to allocate storage units for each containers based on the weight of the materials in the container.

The company has two types of storage units. The first type can hold 5 tonnes, while the second type can hold 10 tonnes. And each of the container is always less than 10 tonnes. If a container has materials with weight less than or equal to 5 tonnes, we must allocate storage unit with the capacity of 5 tonnes. And if it is greater than 5 tonnes, we must allocate the storage unit with the capacity of 10 tonnes.

Write a program to allocate the storage units for the raw materials in the containers.

Input

The first line of input consists of integers, separated by spaces, representing the weight of raw materials in the respective containers.

Output

Print the list with the storage units required to store the raw materials from the respective containers.

As is

The boilerplate code is already there to read the inputs from user, in the main() function. Do not edit this code.

To do ✍

storageUnitAllocation() has one parameter: containerWeights. Complete the function that fills the list storage_units with required storage units, and returns the same.

Example

Test input

4 5 8 7

Test output

[5, 5, 10, 10]

Explanation

For the given input weights,

  • 4 is less than or equal to 5, therefore we allocate a storage unit with the capacity of 5 tonnes.
  • 5 is less than or equal to 5, therefore we allocate a storage unit with the capacity of 5 tonnes.
  • 8 is not less than or equal to 5, therefore we allocate a storage unit with the capacity of 10 tonnes.
  • 7 is not less than or equal to 5, therefore we allocate a storage unit with the capacity of 10 tonnes.

Python Program

# Complete the following function
def storageUnitAllocation(containerWeights):
    storage_units = []
    

    
    return storage_units

# Boilerplate code - Do not edit the following
def main():
    containerWeights = [int(item) for item in input().split()]
    print(storageUnitAllocation(containerWeights))

if __name__ == "__main__":
    main()

Input and Outputs 1

5 6 1 0 8
[5, 10, 5, 5, 10]

Input and Outputs 2

8 7 9 4 1 2 3
[10, 10, 10, 5, 5, 5, 5]

Input and Outputs 3

8
[10]

Input and Outputs 4

0
[5]
# Complete the following function
def storageUnitAllocation(containerWeights):
    storage_units = []
    for weight in containerWeights:
        if weight <= 5:
            storage_units.append(5)
        else:
            storage_units.append(10)
    return storage_units

# Boilerplate code - Do not edit the following
def main():
    containerWeights = [int(item) for item in input().split()]
    print(storageUnitAllocation(containerWeights))

if __name__ == "__main__":
    main()
show answer
main.py
⏵︎ Run Tests
Reset
Download
×
Code copied to clipboard successfully 👍