Question: CODE IN PYTHON PLEASE miu puzzle: Rule 1: If your string ends in an I, you can add a U on the end: x I

 CODE IN PYTHON PLEASE miu puzzle: Rule 1: If your string

CODE IN PYTHON PLEASE

miu puzzle:

Rule 1: If your string ends in an I, you can add a U on the end: x I x IU

Rule 2: If the string starts with M, you can double what comes after the M: M x M x x

Rule 3: If you have III in a string, you can replace it with a U: x III y x U y

Rule 4: If you have UU in a string, you can delete it altogether: x UU y x y

The next_states(s) functon - def next_states(s) - Given a string, s, as input, return a list of all possible strings that can be derived from s in a single step. - 1. next-states ("MI") ["MIU", "MII"] - 2. next-states ("MIU") ["MIUIU"] - 3. next-states ("MUI") ["MUIU", "MUIUI"] - 4. next-states("MIIII") ["MIIIIU", "MIIIIIIII", "MUI", "MIU"] - 5. next-states ("MUUII") ["MUUIIU", "MUUIIUUII", "MII"] - 6. next-states("MUUUI") ["MUUUIU", "MUUUIUUUI", "MUI"] - the rules must be applied in the order that they are given above - if there is more than one way to apply a rule, the results must be ordered so that the application is done in a left-to-right order (see example 4) - the resulting list must contain no duplicates: if a string is already in the result from an earlier application of a rule, don't add it again (see example 6) - Write this function and then test it with the examples above (and others)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!