Submit solution


Points: 10 (partial)
Time limit: 1.0s
Memory limit: 32M

Author:
Problem type
Allowed languages
Python

You are given four parameters, a, b, c, and d.

a and b represent the range of multipliers, while c and d represent the range of multiplicands.

If no parameters are given, assume default values of a=1, b=9, c=1, and d=9, with the additional constraint that a \leq b and c \leq d.

Your task is to generate a list of all possible products that can be obtained by multiplying any number from the range [a, b] with any number from the range [c, d].

Return this list of products as your solution, sorted based on the order in which the products are generated.

To generate the list of products, you should multiply a with c, a with c+1, ..., a with d, then a+1 with c, a+1 with c+1, ..., (a+1) with d, and so on, up to b with d.

In other words, you should loop through all possible combinations of multipliers and multiplicands in the following order:

a*c, a*(c+1), ..., a*d
(a+1)*c, (a+1)*(c+1), ..., (a+1)*d
...
b*c, b*(c+1), ..., b*d

Your function should be defined as follows:

def get_products(a=1, b=9, c=1, d=9):
    # your code here
    pass

You should assume that the function will be called with named arguments, and that the order of the arguments may not be consistent across function calls.

You only need to submit the functions get_products. You should not read from stdin or write to stdout, e.g. calling print() and input().

Input Specification

The sample input shows how your functions will be called.

Limits

Memory limits: 32MB.

Time limits: 1 second.

1 \leq T \leq 100

1 \leq N \leq 100

1 \leq a \leq b \leq 9

1 \leq c \leq d \leq 9

Ouput Specification

For each function call, you must return exactly what we asked for.

Test Set 1

Sample Case

Test Set 2

1 \leq N \leq 100

Sample Input

get_products(a=1,b=2,c=1,d=4)

Sample Output

[1, 2, 3, 4, 2, 4, 6, 8]

Comments

There are no comments at the moment.