Python program for calculating the odds for Arnie’s F-bomb

#!/usr/local/bin/pythonw
# Copyright (c) 2009 by Amos Newcombe

Msg = '''
To the Members of the California State Assembly:

I am returning Assembly Bill 1176 without my signature.

For some time now I have lamented the fact that major issues are overlooked while many
unnecessary bills come to me for consideration. Water reform, prison reform, and health
care are major issues my Administration has brought to the table, but the legislature just
kicks the can down the alley.

Yet another legislative year has come and gone without the major reforms Californians
overwhelmingly deserve. In light of this, and after careful consideration, I believe it is
unnecessary to sign this measure at this time.

Sincerely,

Arnold Schwarzenegger
'''

import string

FreqTable = {}
c = 0.
for ch in Msg:
    if ch in string.ascii_lowercase:
        pass
    elif ch in string.ascii_uppercase:
        ch = ch.lower()
    else: continue
    FreqTable[ch] = FreqTable.get(ch, 0) + 1
    c += 1.
for ch in FreqTable: FreqTable[ch] /= c

probability = 1.
for ch in 'fuckyou':
    probability *= FreqTable[ch]
print 'probability = %g, or 1 chance in %.0f' % (probability, 1/probability)

Here is the background.

Leave a Reply