Question
In [ ]: Write a function that can solve this problem, i.e. computer, y, and b from a given list of orders and corresponding
In [ ]: Write a function that can solve this problem, i.e. computer, y, and b from a given list of orders and corresponding total prices. It happens that this isn't the first time this has occurred at the company. It will probably happen again. We want to make a function that will work on different numbers of widgets and orders. You talked to someone in IT, and they are only able to get you the data in the following format: orders [monday, zeta, party] totals [2087, 1976, 411] where list entries are defined above. Your function should take 2 input arguments, orders and totals, where orders is a list of arbitrary widgets (one order is essentially the same as one composite widget), and totals is a list of the total prices for each order. Your function should return a list of 3 numbers [r, y, b], representing the respective prices of each raw material. Because of outdated computer systems, you absolutely need to return the prices rounded to the nearest 0.01. Partial marks will be given for solutions which assume that there will always be exactly 3 independent orders available in the data. For full marks, your function should also handle the case where data for more than 3 orders is available. You can assume that, in all cases, any given set of orders will consist of at least 3 linearly independent combinations of the raw materials. For instance, this would be a valid order: orders [monday, zeta, monday + 2*zeta, party] totals = [631.18, 604.64, 1840.46, 169.02] # Testing importlib.reload (task2); orange = 2*red + 4*yellow purple 5*red + 4*blue brown = 4*red + 7*yellow + 18 *blue monday = 4*orange + 7*purple + 10*brown. zeta = 5*orange + 10*purple + 8*brown party = 9*orange + 3*purple assert task2.reconstruct_prices ([monday, zeta, party], [2087, 1976, 411]) == [7, 3, 6] assert task2.reconstruct_prices ([monday, zeta, monday + 2*zeta, party], [631.18, 604.64, 1840.46, 169.02]) == [2.5, 2, 1.21] print('All tests passed.')
Step by Step Solution
There are 3 Steps involved in it
Step: 1
![blur-text-image](https://dsd5zvtm8ll6.cloudfront.net/includes/images/document_product_info/blur-text-image.webp)
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
![blur-text-image](https://dsd5zvtm8ll6.cloudfront.net/includes/images/document_product_info/blur-subtext-image.webp)
Step: 3
![blur-text-image](https://dsd5zvtm8ll6.cloudfront.net/includes/images/document_product_info/blur-subtext-image.webp)
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started