Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Required File Name: Program_15_1.m The infinite monkey theorem states that a monkey hitting keys at random on a typewriter keyboard for an infinite amount of

Required File Name: Program_15_1.m The infinite monkey theorem states that a monkey hitting keys at random on a typewriter keyboard for an infinite amount of time will almost surely type the complete works of William Shakespeare. In this program you will put this theorem to the test by using the rand() function to create random sequences of letters and the underscore symbol until the desired sequence is created. While attempting to create the desired sequence you must count the number of random attempts needed to create the sequence and measure the time to create the sequence. Our ultimate goal is to create the phrase: to_be Please note that it will take a few minutes on average to randomly generate this phrase. A sample of the required output is shown on the next page. Run you program two times and include the output for the two trials. Output for Program_15_1 written by John Wadach. The attempted sequence is: t It took 13 attempts to create the sequence: t Elapsed time is 0.001358 seconds. The attempted sequence is: to It took 235 attempts to create the sequence: to Elapsed time is 0.009133 seconds. The attempted sequence is: to_ It took 26653 attempts to create the sequence: to_ Elapsed time is 0.555479 seconds. The attempted sequence is: to_b It took 98377 attempts to create the sequence: to_b Elapsed time is 2.062023 seconds. The attempted sequence is: to_be It took 1.90588e+007 attempts to create the sequence: to_be Elapsed time is 420.934171 seconds. >> Note: You can see that it would take the monkey quite a while to just type this short phrase from Hamlet without any errors. To be, or not to be, that is the question: Whether 'tis nobler in the mind to suffer The slings and arrows of outrageous fortune, Or to take arms against a sea of troubles And by opposing end them.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

Automating Access Databases With Macros

Authors: Fish Davis

1st Edition

1797816349, 978-1797816340

More Books

Students also viewed these Databases questions

Question

technologies on organizations.

Answered: 1 week ago