Claude Shannon1 (1916-2001) — the father of information theory — took an active interest in juggling. He used to juggle balls while riding a unicycle through the halls of Bell Labs2, and he built the first juggling robot from an Erector Set3 in the 1970s. The machine below mimics W.C. Fields4, who himself juggled in vaudeville before turning to comedy.

Noting that juggling seems to appeal to mathematics-minded people, Shannon offered the following theorem: \[H(F + D) = B(V + D)\] where $$H$$ is the number of hands, $$F$$ the time a ball spends in the air (flight time), $$D$$ the time a ball spends in the hand (dwell time), $$V$$ the time a hand spends empty (vacant time) and $$B$$ the number of balls.

He wrote:

The juggling equation allows one to calculate the range of possible periods (time between hand throws) for a given type of uniform juggle and a given time of flight. A juggler can change this period, while keeping the height of his throws fixed, by increasing dwell time to increase the period or reducing dwell time to reduce the period. The total mathematical range available for a given flight time can be obtained by setting $$D = 0$$ for minimum range and $$V = 0$$ for maximum range in the juggling equation. The ratio of these two extremes is independent of the flight time and dependent only on the number of balls and hands.

To measure dwell times, Shannon actually created a "jugglometer" in which a juggler wore copper mesh over his fingers and juggled foil-covered lacrosse balls. Catching the ball closed a connection between the fingers and started a clock.

Preliminary results from testing a few jugglers indicate that, with ball juggling, vacant time is normally less than dwell time, $$V$$ ranging in our measurements from fifty to seventy per cent of  $$D$$.

Shannon noted that juggling gets dramatically harder as the number of balls increases. He worked out a foolproof solution, at least in theory. A light ray that starts at one focus of an ellipse will be reflected to the other focus. If the ellipse is rotated around its major axis, it will create an egg-like shell with two foci. Now if a juggler stands with a hand at each focus, then a ball thrown from either hand, in any direction, will bounce off the shell and arrive at the other hand!

Assignment

If $$n - 1$$ parameter values are known for a linear equation with $$n \in \mathbb{N}$$ parameters (with $$n \geq 2$$), the missing parameter value can be computed directly from the formula. In this assignment we apply this on the juggling equation.

The parameters of an equation are represented as a container of strings (a string, a list, a tuple or a set), where each string contains a valid name for a parameter of a Python function (the same naming rules apply as for variables: names only contain letters, digits and underscore and do not start with a digit). All parameter names should also be different. Your task:

Example

>>> missing_parameter({'F':1.2, 'D':0.6, 'H':2, 'B':4}, 'FDVBH')
'V'
>>> missing_parameter({'D': 0.6, 'B': 4, 'V': 0.3, 'H': 2}, 'FDVBH')
'F'
>>> missing_parameter({'F':1.2, 'D':0.6, 'H':2, 'X':4}, 'FDVBH')
Traceback (most recent call last):
AssertionError: invalid parameters
>>> missing_parameter({'F':1.2, 'D':0.6, 'H':2}, 'FDVBH')
Traceback (most recent call last):
AssertionError: invalid parameters

>>> juggle({'F':1.2, 'D':0.6, 'H':2, 'B':4})
{'F': 1.2, 'D': 0.6, 'B': 4.0, 'V': 0.3, 'H': 2.0}
>>> juggle({'D': 0.6, 'B': 4, 'V': 0.3, 'H': 2})
{'D': 0.6, 'V': 0.3, 'F': 1.2, 'H': 2.0, 'B': 4.0}
>>> juggle({'F':1.2, 'D':0.6, 'H':2, 'X':4})
Traceback (most recent call last):
AssertionError: invalid parameters

>>> juggler(F=1.2, D=0.6, H=2, B=4)
{'F': 1.2, 'D': 0.6, 'B': 4.0, 'V': 0.3, 'H': 2.0}
>>> juggler(D=0.6, B=4, V=0.3, H=2)
{'D': 0.6, 'V': 0.3, 'F': 1.2, 'H': 2.0, 'B': 4.0}
>>> juggler(F=1.2, D=0.6, H=2, X=4)
Traceback (most recent call last):
AssertionError: invalid parameters

Resources