Write a function called monkey_experiment that takes in a goal string (e.g., "methinks it is like a weasel") and a number of iterations as an argument. Run the experiment for that many iterations, and...


Write a function called monkey_experiment that takes in a goal string (e.g., "methinks it is like a weasel") and a number of iterations as an argument. Run the experiment for that many iterations, and return a tuple with the highest-scoring text that was generated along with the score that it got.



Test results:



>>> monkey_experiment("methinks it is like a weasel",100000)


('m ojindoebjrerloiuc m oaanvl', 8)


>>> monkey_experiment("methinks it is like a weasel",100)


('yeanpqj twosisjcvqrrfu eagbi', 5)


>>> monkey_experiment("brevity is the soul of wit",100000)


('nnebptorcrytbe wogl uygdsn', 8)


>>> monkey_experiment("to be",100000)


('tofbe', 4)


>>> monkey_experiment("to be",200000)


('tbhbe', 3)


>>> monkey_experiment("to be",500000)


('eo be', 4)



Jun 01, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here