Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

rechal1stone.length 7L Part Il: Recursive Work Order Calculator (20 points) Wrile a recarsive function zec.work.cost(thttakes two arguments, in this oeder I, work.orders: a list of

image text in transcribed
rechal1stone.length 7L Part Il: Recursive Work Order Calculator (20 points) Wrile a recarsive function zec.work.cost(thttakes two arguments, in this oeder I, work.orders: a list of strings epresenting work ceders 2hourly.costs:a tuple of theee integers sepresenting the costs per hour to fix a pipe, window and sprin- kler, respectively Each work order in workordersstarts with a single digit and is followed by "pipe."window or sprinkier The digit indicates the nember of hours that will be spent repairing the piven inem. For instance. Ssprinkler ndicates that it will take 5 hours to repair a particular sprinkler. For the moment, assuming that hourly oosts 16 2,9).This means that it will cost x 9-S45 to repair the sprinkler. In general, hourly.costs will contain a dif erent trio o valoes The function recarsively processes the entire list of work orders and returns the total cost of performing all the One possible recursive algorihm you can consider implementing is this: if work orders is erpty then otherwise return let renaining costs be the cost of completing all of the other work orders CSE 101 -Spring 2018 #7 Pape 2 t workorders01is for a pipe then othervise, if work orderst01 is for a window then othervise, work ordersto1 must be for a sprinkler, so .e, work ordersil and al1 later work orders) return (the coat to repaiz the piperemaining costs) return the cost to repair the window renaining..costs) return (the coat to repair the sprinklerremainingcosts) Node Non-recursive solutions to the peolem that use loops will not earn credit Exampless Functicn Cal ree work.costilt,isprinkler,_T4window, 3pipe.Twindow, Return Value 1.04 pipe, Spipe2window. 17. 4.61 cost I 3pipe'3sprinkler'. 4pipe3pipe" 1pipe" 3window2sprinkler"4spinkler 3pipe 4window 3, 6)3 rec.work.cost E'2plpe 4pipe4pipe3sprinkler 4windowspzinkle 6, 4. 513 rec work.cost (LL'3window,window', 1sprinkler, 4indou'66 rec.work.COSE IL 4wLndow3window, 2pipe,2sprinkler 94 105 ree woxk.cost L 1window'3pipe3windo3window .3sprinkler,, ,2sprinkler.], (7.7, .4sprinkler','2sprinkler"], , 5, 31]) 3window2window4sprinkler.1window2sprinkler. rec.work.coSt (LL 3sprinkler". 2sprinkler.2pipe'pipe64 12. 35)D rec.work.coSt (Ll 4plpe4sprinkler 4sprinkler'3wLndow155 How to Submit Your Work for Grading To sabmit your py Sle for grading: I. Login to Blackboard and locate the course accouns for CSE 101

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

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

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions