Given a collection of items, with each item written as [Color, Size], produce one list containing every distinct color and another list containing every distinct size arranged from smallest to largest. Built-in sorting operations and hard-coded solutions are not permitted.
items: A two-dimensional list containing item records. Each record has the form [Color, Size].colors: A list of strings containing the distinct colors found in items.sizes: A list of strings containing the distinct sizes found in items, ordered ascendingly.items = [
["Red", "S"],
["Red", "M"],
["Red", "L"],
["Blue", "XS"],
["Blue", "S"],
["Blue", "L"]
]
Output:
Colors: ['Red', 'Blue']
Sizes: ['XS', 'S', 'M', 'L']
input = [['Red', 'S'], ['Red', 'M'], ['Red', 'L'], ['Blue', 'XS'], ['Blue', 'S'], ['Blue', 'L']](['Red','Blue'], ['XS', 'S', 'M', 'L'])
The input is 6 items. Each has a color and a size.
The color list contains each color once, while the size list contains each available size once in ascending order.
1 <= len(items) <= 1000'XS', 'S', 'M', 'L', 'XL', and 'XXL'.input = [['Red', 'S'], ['Red', 'M'], ['Red', 'L'], ['Blue', 'XS'], ['Blue', 'S'], ['Blue', 'L']](['Red','Blue'], ['XS', 'S', 'M', 'L'])
The input is 6 items. Each has a color and a size.