question archive A solution to the MCGW problem can be expressed in different forms, but it is not as simple for human to verify whether a given solution is correct
Subject:Computer SciencePrice: Bought3
A solution to the MCGW problem can be expressed in different forms, but it is not as simple for human to verify whether a given solution is correct. Here we are to deveIOp a Python program to help verifying the correctness of a given solution. To solve the problem systematically, we are to deveIOp a few ?mctions and break up the original bigger problem into several smaller problems. The following order of breaking down the problem is not the only way, but is a reasonable way. You can assume that the input string is correct in that it does not contain any special character, nor there is a missing of key symbols like " " and ">". - Given a cleaned list from (a) showing the sequence of states of a potential solution, develop a Python function check(stateList). It would take in a list of states and print out the solution if it is correct. If it is incorrect, indicate the step(s) where there is a problem. There are three types of possible problems: (1) the start and end states are incorrect, i.e., not IMCGW and MCGWI reSpectively; (2) a state is illegal, i.e. either the wolf eating the goat or the goat eating the cabbage; (3) a move is not allowed, e.g. man does not move (perhaps the wolf swims or the cabbage "swims"), or the man carries more than one item. Provide appropriate comments in your function. To develop this function, you would need to develop some auxiliary functions as in (c) and (d) ?rst. You may assume that those two functions in (c) and (d) are available to you when you develop this function for (b) at this moment. Here are some sample outputs ?'om your function: >>> print(check(cleanup("l IICGW > G l HCW > C l HGW > CW I HG > HCWG l'))) The love lm -> GI" is not allowed The love GI" -> CIR?! is not allowed "113ml: nave CIIIGW -> CIIIIG is not allowed a se 'l'» print(check(cleannp("lHCGW >MGICW >GIMCW >HGW|C >11"ch >wcmlg >cwlmg >cwmgl'))) rue >>> print(check(cleanup("llw I CG > W I MCG"))) Start state mos is incorrect The state IMO} is illegal End state IIICG is incorrect False