Football announcers are always pontificating about the importance of momentum.
Of course, whenever the team that doesn't have the momentum does something
good, the explanation is that the momentum has shifted. We want to do a
study of football games to determine how big a role momentum actually plays.
We define the "mfactor" to be the number of scores that immediately follow a score by
the same team minus the number of scores that immediately follow a score by the opponent.
So if "ABBAAAAAB" were the sequence of scores in a game between teams A and B,
then the mfactor would be 5  3 = 2. (The 5 comes from one time that a score by B was immediately followed by another score by B and four times that a score by A was immediately followed by a score by A. Similarly, the 3 comes from the one BA and the two AB's that occur.)
But we have to be careful. A high mfactor will naturally occur if one team is
just a lot better than the other. If only one team scores, no score will follow
a score by the opponent. So to judge whether
momentum played an important role, we have to compare the mfactor for a game
to the random mfactor for the given number of scores by the two teams.
For a game with n scores, the random mfactor is defined to be the average of
the n! mfactors corresponding to the n! (not necessarily distinct) permutations of the scores. For example,
the random mfactor of the game "ABA" is the average of the 6 mfactors corresponding
to "ABA", "AAB", "BAA", "BAA", "AAB", "ABA".
Create a class NoMo that contains a method momentum that is given a String
game giving the sequence of scores
by teams A and B and that returns the mfactor for the game minus the random
mfactor for that number of scores by A and B.
