{"id":15,"date":"2019-10-02T16:06:04","date_gmt":"2019-10-02T16:06:04","guid":{"rendered":"http:\/\/iheinrich.com\/?p=15"},"modified":"2019-10-02T20:23:17","modified_gmt":"2019-10-02T20:23:17","slug":"lucky-ticket","status":"publish","type":"post","link":"https:\/\/iheinrich.com\/index.php\/2019\/10\/02\/lucky-ticket\/","title":{"rendered":"Lucky Ticket"},"content":{"rendered":"\n<p>While on the bus in Russia, they give you a ticket with a 6 digit number.<\/p>\n\n\n\n<p>The Russian I was with closely read the numbers, and I asked \u201cWhy do you care about the number?\u201d<\/p>\n\n\n\n<p>She said, \u201cIf the first three numbers equal the last three numbers, it\u2019s a \u2018Happy Ticket\u2019 and I keep it.\u201d<\/p>\n\n\n\n<p>I tried to figure the odds on getting a \u201cHappy Ticket\u201d and just gave up.<\/p>\n\n\n\n<p>I\u2019m a programmer, not a mathematician.<\/p>\n\n\n\n<p>So I wrote a Ruby script to iterate thru the numbers and do a comparison of the first three and the last three.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/usr\/bin\/env ruby\ni = 0\nhappy = 0\ntheCount = Array.new\nwhile i &lt; 999999\ni += 1\nf = sprintf '%06d', i # f is a six digit number\n\ntheCount = f.chars.to_a\n\nfirst = theCount.fetch(0).to_i + theCount.fetch(1).to_i + theCount.fetch(2).to_i\nlast = theCount.fetch(3).to_i + theCount.fetch(4).to_i + theCount.fetch(5).to_i\n\n     if first == last\n          happy += 1\n          print(\"Happy Number \", happy,\" is \", theCount[0..2], theCount[3..5], \"\\n\") \n      end\n\nend\n<\/code><\/pre>\n\n\n\n<p>The end result is that there are 55,252 &#8216;Happy Numbers&#8217;, meaning your odds of getting one is about 5.5%<\/p>\n","protected":false},"excerpt":{"rendered":"<p>While on the bus in Russia, they give you a ticket with a 6 digit number. The Russian I was&#8230;<\/p>\n","protected":false},"author":1,"featured_media":16,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[5],"tags":[3,4],"class_list":["post-15","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ruby","tag-ruby","tag-russia","wpcat-5-id"],"_links":{"self":[{"href":"https:\/\/iheinrich.com\/index.php\/wp-json\/wp\/v2\/posts\/15","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/iheinrich.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/iheinrich.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/iheinrich.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/iheinrich.com\/index.php\/wp-json\/wp\/v2\/comments?post=15"}],"version-history":[{"count":2,"href":"https:\/\/iheinrich.com\/index.php\/wp-json\/wp\/v2\/posts\/15\/revisions"}],"predecessor-version":[{"id":18,"href":"https:\/\/iheinrich.com\/index.php\/wp-json\/wp\/v2\/posts\/15\/revisions\/18"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/iheinrich.com\/index.php\/wp-json\/wp\/v2\/media\/16"}],"wp:attachment":[{"href":"https:\/\/iheinrich.com\/index.php\/wp-json\/wp\/v2\/media?parent=15"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/iheinrich.com\/index.php\/wp-json\/wp\/v2\/categories?post=15"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/iheinrich.com\/index.php\/wp-json\/wp\/v2\/tags?post=15"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}