Let U denote a Uranium cube and L denote a Lead cube. A stack of 5 cubes is considered hazardous if it contains a sequence of three or more Uranium cubes together (i.e., contains the substring UUU).
We can find the number of hazardous combinations by considering the number of Uranium cubes in the stack. A hazardous stack must have at least 3 Uranium cubes.
Case 1: The stack has exactly 3 Uranium cubes.
For the stack to be hazardous, all three U cubes must be adjacent. The other two cubes must be L. The possible arrangements are:
UUU L L
L UUU L
L L UUU
This gives 3 hazardous combinations.
Case 2: The stack has exactly 4 Uranium cubes.
The stack has 4 U's and 1 L. We need to find the arrangements that contain the substring UUU. There are 5 possible positions for the single L cube:
L UUUU (Hazardous)
U LUUU (Hazardous)
UU LUU (Not hazardous)
UUU LU (Hazardous)
UUUU L (Hazardous)
This gives 4 hazardous combinations.
Case 3: The stack has exactly 5 Uranium cubes.
The only possible arrangement is UUUUU. This contains the substring UUU, so it is hazardous.
This gives 1 hazardous combination.
Total number of hazardous combinations = (Combinations from Case 1) + (Combinations from Case 2) + (Combinations from Case 3)
Total = 3 + 4 + 1 = 8.