{"id":907,"date":"2013-12-17T03:39:44","date_gmt":"2013-12-17T08:39:44","guid":{"rendered":"http:\/\/www.xavignu.com\/?p=907"},"modified":"2013-12-17T03:39:44","modified_gmt":"2013-12-17T08:39:44","slug":"project-euler-number-92","status":"publish","type":"post","link":"https:\/\/www.xavignu.com\/?p=907","title":{"rendered":"Project Euler number 92"},"content":{"rendered":"<p>Below is the solution to <a href=\"http:\/\/projecteuler.net\/\" target=\"_blank\">Project Euler<\/a> problem 92. Its written in <a href=\"http:\/\/www.python.org\" target=\"_blank\">python<\/a> and takes about 10 minutes to reach the solution depending on your hardware. There are some comments in the code to know what the program is doing.<\/p>\n<p>[python]<br \/>\n#!\/usr\/bin\/env python<\/p>\n<p>number_89 = 0<\/p>\n<p>for z in range(10000000, 1, -1):<\/p>\n<p>        def chain(z):<br \/>\n                var = z<br \/>\n                chaindigit = 0<br \/>\n                while (chaindigit != 1 or chaindigit != 89):<br \/>\n                        # Transform the number into a string<br \/>\n                        list =  [int(i) for i in str(var)]<br \/>\n                        # Multiply each list member<br \/>\n                        chain = [x * y for x, y in zip(list, list)]<br \/>\n                        # Add the remaining list members<br \/>\n                        chaindigit = sum(chain)<br \/>\n                        var = chaindigit<br \/>\n                        # Check whether it ends in 89 or 1<br \/>\n                        if (chaindigit == 1 or chaindigit == 89):<br \/>\n                                # If it ends in 89 increment the value of number_89<br \/>\n                                if (chaindigit == 89):<br \/>\n                                        global number_89<br \/>\n                                        number_89 = number_89 + 1<br \/>\n                                break<br \/>\n        chain(z)<\/p>\n<p>print &quot;There are&quot;, number_89,&quot;chain numbers that end in 89.&quot;<br \/>\n[\/python]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Below is the solution to Project Euler problem 92. Its written in python and takes about 10 minutes to reach the solution depending on your hardware. There are some comments in the code to know what the program is doing. [python] #!\/usr\/bin\/env python number_89 = 0 for z in range(10000000, 1, -1): def chain(z): var [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true},"categories":[63],"tags":[6,67,70],"jetpack_featured_media_url":"","jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/pTQgt-eD","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.xavignu.com\/index.php?rest_route=\/wp\/v2\/posts\/907"}],"collection":[{"href":"https:\/\/www.xavignu.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xavignu.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xavignu.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xavignu.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=907"}],"version-history":[{"count":3,"href":"https:\/\/www.xavignu.com\/index.php?rest_route=\/wp\/v2\/posts\/907\/revisions"}],"predecessor-version":[{"id":911,"href":"https:\/\/www.xavignu.com\/index.php?rest_route=\/wp\/v2\/posts\/907\/revisions\/911"}],"wp:attachment":[{"href":"https:\/\/www.xavignu.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=907"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xavignu.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=907"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xavignu.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=907"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}