In probability theory, the Mabinogion sheep problem or Mabinogian urn is a problem in stochastic control introduced by David Williams (1991, 15.3), who named it after a herd of magic sheep in the Welsh collection of tales, the Mabinogion.
And he came towards a valley, through which ran a river; and the borders of the valley were wooded, and on each side of the river were level meadows.
And on one side of the river he saw a flock of white sheep, and on the other a flock of black sheep.
At any time one may remove as many sheep (of either color) as one wishes from the flock.
The problem is to do this in such a way as to maximize the expected final number of black sheep.