- Write a problem to simulate the tossing of a sequence of successive coin tosses.
- Search the suitably generated sequence to find a particular pattern, e.g., HTH. Report where this sequence was found – after how many flips in the generated sequence. Allow the user to enter the pattern to look for via the UI (User Interface).
- Modify your program to repeat steps 1 and 2 a variable number of times; allow the user to specify this value in the UI. Each repeat should use the same search pattern, but a new sequence of source coin tosses.
- Modify your program to keep track of where the pattern was found in each generated sequence. Report the overall average number of coin tosses required to the find the search pattern across all of the repeats.
- If your program is correct, you will find that the average number of tosses necessary to find the search pattern HTH is 10, however, HTT it is 8. Why is this (this is another conditional probability problem)?