Generation

generate functionMon, 12 Dec 2022

Create a program that will take two lists of integers, a and b. Each list will consist of 3 positive integers above 0, representing the dimensions of cuboids a and b. You must find the difference of the cuboids' volumes regardless of which is bigger. For example, if the parameters passed are ([2, 2, 3], [5, 4, 1]), the volume of a is 12 and the volume of b is 20. Therefore, the function should return 8. Write solution in one line of code.

def find_difference(a, b): return abs(reduce(lambda x, y: x*y, a) - reduce(lambda x, y: x*y, b))

Questions about programming?Chat with your personal AI assistant