What is the probability of rolling a 6-sided die 5 times, and getting at least 3 in a row? I had been working on this problem, and ran into trouble because I couldn't easily use the "find the opposite probability and subtract from one" trick. So for example I think I can find the probability of getting at least two in a row rolling a die 5 times, by finding the probability of getting no duplicates at all and then subtracting from one to find the opposite: ( 1 - (5/6)^4 )

But how to find the probability of a sequence of at least three? The extension of the problem is to write a formula generalizable to the number of trials, number of possible outcomes per trial, and the length of the repeated sequence. 

I like working on this on my own so if you can just give a little hint or guidance I'd appreciate it very much!
You can do this using inclusion-exclusion. The conditions you want are the three conditions that the first, second or third triple of rolls are all the same. Adding the three counts for each of these conditions being met is straightforward. Then you need to substract the counts for each pair of conditions being met. This is only slightly more involved; you need to take into account that in one case the pair covers all five rolls and in the other two cases it only covers four rolls. Then you need to add the count for all three conditions being met &ndash; this is again straightforward.
The probability of getting exactly 3 in a row is obtained by counting the ways to select a number for those three, two numbers for the others (from the remaining five numbers, duplicates allowed) and choosing the start position for the triple, out of the total ways to roll the dice.$$\frac{6\cdot 4^2\cdot 3}{6^5} = \frac{4^2\cdot 3}{6^4} = \frac{25}{423}$$

Then to obtain the probability of at least three in a row, we also consider exactly 4 in a row, and all the same.$$\frac{5^2\cdot 3+5\cdot 2+1}{6^4} = \frac{43}{648}$$