{"id":30,"date":"2009-10-29T00:43:38","date_gmt":"2009-10-29T04:43:38","guid":{"rendered":"http:\/\/amosnewcombe.info\/wordpress\/?page_id=30"},"modified":"2016-08-31T23:12:30","modified_gmt":"2016-09-01T03:12:30","slug":"python-program-for-calculating-the-odds-for-arnies-f-bomb","status":"publish","type":"page","link":"https:\/\/amosnewcombe.info\/wordpress\/python-program-for-calculating-the-odds-for-arnies-f-bomb\/","title":{"rendered":"Python program for calculating the odds for Arnie&#8217;s F-bomb"},"content":{"rendered":"<pre>#!\/usr\/local\/bin\/pythonw\r\n# Copyright (c) 2009 by Amos Newcombe\r\n\r\nMsg = '''\r\nTo the Members of the California State Assembly:\r\n\r\nI am returning Assembly Bill 1176 without my signature.\r\n\r\nFor some time now I have lamented the fact that major issues are overlooked while many\r\nunnecessary bills come to me for consideration. Water reform, prison reform, and health\r\ncare are major issues my Administration has brought to the table, but the legislature just\r\nkicks the can down the alley.\r\n\r\nYet another legislative year has come and gone without the major reforms Californians\r\noverwhelmingly deserve. In light of this, and after careful consideration, I believe it is\r\nunnecessary to sign this measure at this time.\r\n\r\nSincerely,\r\n\r\nArnold Schwarzenegger\r\n'''\r\n\r\nimport string\r\n\r\nFreqTable = {}\r\nc = 0.\r\nfor ch in Msg:\r\n    if ch in string.ascii_lowercase:\r\n        pass\r\n    elif ch in string.ascii_uppercase:\r\n        ch = ch.lower()\r\n    else: continue\r\n    FreqTable[ch] = FreqTable.get(ch, 0) + 1\r\n    c += 1.\r\nfor ch in FreqTable: FreqTable[ch] \/= c\r\n\r\nprobability = 1.\r\nfor ch in 'fuckyou':\r\n    probability *= FreqTable[ch]\r\nprint 'probability = %g, or 1 chance in %.0f' % (probability, 1\/probability)\r\n\r\n<\/pre>\n<p>Here is <a href=\"https:\/\/amosnewcombe.info\/wordpress\/2009\/10\/29\/what-are-the-odds\/\" target=\"_blank\">the background<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>#!\/usr\/local\/bin\/pythonw # Copyright (c) 2009 by Amos Newcombe Msg = &#8221;&#8217; 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 &hellip; <a href=\"https:\/\/amosnewcombe.info\/wordpress\/python-program-for-calculating-the-odds-for-arnies-f-bomb\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"open","ping_status":"open","template":"","meta":{"footnotes":""},"class_list":["post-30","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/amosnewcombe.info\/wordpress\/wp-json\/wp\/v2\/pages\/30","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/amosnewcombe.info\/wordpress\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/amosnewcombe.info\/wordpress\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/amosnewcombe.info\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/amosnewcombe.info\/wordpress\/wp-json\/wp\/v2\/comments?post=30"}],"version-history":[{"count":5,"href":"https:\/\/amosnewcombe.info\/wordpress\/wp-json\/wp\/v2\/pages\/30\/revisions"}],"predecessor-version":[{"id":493,"href":"https:\/\/amosnewcombe.info\/wordpress\/wp-json\/wp\/v2\/pages\/30\/revisions\/493"}],"wp:attachment":[{"href":"https:\/\/amosnewcombe.info\/wordpress\/wp-json\/wp\/v2\/media?parent=30"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}