Answered step by step
Verified Expert Solution
Question
00
1 Approved Answer
Please do in python Part II: Recursive Work Order Calculator (20 points) Write a recursive function rec.work.cost ) that takes two arguments, in this order:
Please do in python Part II: Recursive Work Order Calculator (20 points) Write a recursive function rec.work.cost ) that takes two arguments, in this order: 1. work.orders: a list of strings representing work orders 2. hourly.costs: a tuple of three integers representing the costs per hour to fix a pipe, window and sprin- kler, respectively Each work order in work.orders starts with a single digit and is followed by pipe, 'window' or' sprinkler' The digit indicates the number of hours that will be spent repairing the given item. For instance, ' 5sprinkler indicates that it wil take 5 hours to repair a particular sprinkler. For the moment, assuming that hourly.costs = (6, 2, 9). This means that it will cost 5 S9 = $45 to repair the sprinkler. In general, hourly costs will contain a different trio of values. The function recursively processes the entire list of work orders and returns the total cost of performing all the work orders One possible recursive algorithm you can consider implementing is this: if work orders is empty then otherwise return 0 let remaining_costs be the cost of completing all of the other work orders if work_orders[0 is for a pipe then otherwise, if work_orders [0 is for a window then otherwise, work_orders (0] must be for a sprinkler, so (i.e., work_orders1 and all later work orders) return (the cost to repair the pipe remaining.costs return (the cost to repair the window remaining costs) return (the cost to repair the sprinkler remaining costs) Note: Non-recursive solutions to the problem that use loops will not earn credit
Please do in python
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started