No he can't send you the code. You have to do it yourself.
Another solution is a count of repeated symbols. You just need a "last_flip" value initialized to an unused value (e.g., -1), and a count variable. count should start at 1 (since there is always "one in a row") and the count should be incremented anytime the current flip equals the last flip.
BTW, does anyone know how to calculate the average mathematically? It seems that the exact answer for the average of 3-in-a-row is 7, which is 2**3 - 1. In a simulation from 1-in-a-row to 10-in-a-row I get the following results, which are in line with the formula 2^n - 1.
Code:
min max average
1 1 1.00
2 22 3.00
3 59 7.02
4 188 15.02
5 375 31.03
6 820 62.93
7 1537 127.06
8 3549 254.79
9 7086 510.40
10 14034 1022.82