There are two types of tables X and Y , let assume the X is the shorter one and Y is more longer. the combination must be occurred between the two types of tables to be aligned and filling up the given distance. We can use a few number of tables to cover all the required distance as possible. Hence, you are required to find the optimum combination to keep the remaining empty distance is as small as possible. [Hint: the first priority is to minimize the empty distance, and the second priority is to minimize the number of used tables] Examples: Input: X = 3, Y = 5, D = 24 The optimum combination is: TX = 3, TY = 3, RD = 0 It means: three tables of size X (TX), three tables of size Y (TY), and remaining distance (RD) is 0. 3 * 3 + 3 * 5 = 24 So empty distance = 24 - 24 = 0 Input: X = 3, Y = 9, D = 29 Output: TX =0, TY = 3, RD = 2 It means: zero tables of size X (TX), three tables of size Y (TY), and remaining distance (RD) is 2. 0 * 3 + 3 * 9 = 27 So empty distance = 29 - 27 = 2 1- Design an algorithm to solve this problem by using loop and if statement with providing full comments on the code. u should make your algorithm efficient. 2- Implement the algorithm using OUBuild script following the above steps (with screenshot of the OUBuild script). 3- Provide 2 screenshots, one for the two examples input and output and one for any other input and output
There are two types of tables X and Y , let assume the X is the shorter one and Y is more longer. the
combination must be occurred between the two types of tables to be aligned and filling up the given
distance. We can use a few number of tables to cover all the required distance as possible. Hence, you are
required to find the optimum combination to keep the remaining empty distance is as small as possible.
[Hint: the first priority is to minimize the empty distance, and the second priority is to minimize the number
of used tables]
Examples:
Input: X = 3, Y = 5, D = 24
The optimum combination is: TX = 3, TY = 3, RD = 0
It means: three tables of size X (TX), three tables of size Y (TY), and remaining distance
(RD) is 0.
3 * 3 + 3 * 5 = 24
So empty distance = 24 - 24 = 0
Input: X = 3, Y = 9, D = 29
Output: TX =0, TY = 3, RD = 2
It means: zero tables of size X (TX), three tables of size Y (TY), and remaining distance (RD) is 2.
0 * 3 + 3 * 9 = 27
So empty distance = 29 - 27 = 2
1- Design an
comments on the code.
u should make your algorithm efficient.
2- Implement the algorithm using OUBuild script following the above steps (with screenshot of the
OUBuild script).
3- Provide 2 screenshots, one for the two examples input and output and one for any other input and output
Step by step
Solved in 3 steps with 1 images