You're playing pinball. When you first shoot a ball it randomly comes down through 1 of 3 gates. When you go through an unlit gate, it lights up. Similarly, a lit gate will go out. What is the expected number of balls you have to throw for all 3 gates to light up?

For example, ball A could go through gate 2, B through gate 3, and C through gate 1. This scenario took 3 rolls and has probability `1/27`

.

I've put serious thought into this question twice over the last couple of years but my answer gets more and more complicated until my brain explodes.

**Follow up**

Douglas hit the nail on the head. For kicks, here's the Python script I used as a reality check for both the 2 and 3 gate cases.

```
from random import randint
def pinball(gates):
trials = []
for trial in range(10000):
state = [False for g in range(gates)]
balls = 0
while not all(state):
gate = randint(0, len(state) - 1)
state[gate] = not state[gate]
balls += 1
trials.append(1.0 * balls)
print sum(trials) / len(trials)
pinball(2)
pinball(3)
```