82.2k views
3 votes
Define a function group-by-nondecreasing, which takes in a stream of numbers and outputs a stream of lists, which overall has the same numbers in the same order, but grouped into segments that are non-decreasing.

User Lubiluk
by
5.5k points

1 Answer

2 votes

Answer:

def group_by_nondecreasing( *args ) :

num_list = [arg for arg in args]

sorted_numlist = sorted( num_list )

list_stream = [ sorted_numlist, sorted_numlist, sorted_numlist ]

return list_stream

Step-by-step explanation:

This python function has the ability to accept multiple and varying amount of arguments. the list comprehension shorten the logical for statement to generate a list of numbers, sorts the list in ascending order by default and duplicates the list in another list.

User HpTerm
by
4.7k points