A function generates a perfectly random number (from 0 to 31, both inclusive) one at a time and stops working once a "pattern" has emerged.
Pattern in this scenario is a concecutive group of numbers that repeated more than 2 times consecutively. What I mean by that?
Example: 6,8,1,9,15,7,9,15,17,9,15,7. See the 9,15,7 pattern? Yeah.
Another example: 9,3,17,5,17,5,17,5,17,5. "Pattern" is 17,5
This pattern needs to be strictly consecutive.
Like: 1,4,8,5,29,4,7,5,29,4,7,5,8,29,4,7,5. See the 29,4,7,5 pattern? Yeah, that doesn't count because the bold 8 is breaking the game here.
No limit exists for their length at all. (Though chances are the pattern will contain only a single number, but still)
Here are 2 questions:
1: Given that l is the lenth of the numbers generated, what is the probability of a pattern occurence?
2: Given that x is the number of different numbers function is allowed to generate, what is the expected number of length for a pattern occurence?