{"id":38016,"date":"2016-10-14T23:23:16","date_gmt":"2016-10-15T04:23:16","guid":{"rendered":"http:\/\/danigguemez.wordpress.com\/?p=477"},"modified":"2016-10-14T23:23:16","modified_gmt":"2016-10-15T04:23:16","slug":"yo-soy-196","status":"publish","type":"post","link":"https:\/\/kenscourses.com\/tc101fall2016\/syndicated\/yo-soy-196\/","title":{"rendered":"Yo soy 196"},"content":{"rendered":"<p class=\"syndicated-attribution\"><em> --Originally published at <a href=\"https:\/\/danigguemez.wordpress.com\/2016\/10\/15\/yo-soy-196\/\"><a href=\"https:\/\/danigguemez.wordpress.com\">Fundamentos de Programaci\u00f3n<\/a><\/a><\/em><br \/><\/p>\n<p>Long time ago I tweeted that I was going to do all the proyects from a previous Ken&#8217;s course but it&#8217;s been a long time and I haven&#8217;t \u00a0posted a single solution.<\/p>\n<p><img class=\"alignnone size-full wp-image-481\" src=\"https:\/\/danigguemez.files.wordpress.com\/2016\/10\/0mabexr_700wa_0.gif?w=676\" alt=\"0mabexr_700wa_0\"   \/>+<\/p>\n<p>It&#8217;s not that I haven&#8217;t done them, is just that I didn&#8217;t know which one to post, so I chose the lychrell number challenge because I thought it was really interesting, I didn\u00b4t even knew that kind of numbers had a name!<\/p>\n<p>So here is what the challenge said:<\/p>\n<h1 class=\"entry-title\">WSQ11 \u2013 Yo Soy 196<\/h1>\n<div class=\"entry-content\">\n<h2><\/h2>\n<p>Lychrel numbers are natural numbers that do not form a palindrome after successive additions to their inverse. See details on Wikipedia:<a title=\"Wikipedia entry for Lychrel Number\" href=\"http:\/\/en.wikipedia.org\/wiki\/Lychrel_number\">http:\/\/en.wikipedia.org\/wiki\/Lychrel_number<\/a><\/p>\n<h2>What to Do<\/h2>\n<p>Your jobs is to create a program that asks the user for two pieces of data:<\/p>\n<ul>\n<li>The lower bound of the sequence<\/li>\n<li>The upper bound of the sequence<\/li>\n<\/ul>\n<div>Then you check the values from the lower bound (inclusive) to the upper bound (inclusive) and make a report of them. During the analysis of each number, if a Lychrel number is found it should be reported immediately with something like \u201cFound a Lychrel number: 196\u201d<\/div>\n<h2>Details<\/h2>\n<div>The report must show:<\/div>\n<div>\n<ul>\n<li>The range of numbers analysed (lower to upper bound)<\/li>\n<li>The number of natural palindromes (no addition to inverse needed)<\/li>\n<li>The number of non-Lycherels encountered (become palindromes)<\/li>\n<li>The number of Lycherel number candidates (that did not converge to palindrome)<\/li>\n<\/ul>\n<\/div>\n<p>Since you will not be able to prove that a number is Lycherel (since you cannot computer forever to check), our definition for a Lycherel candidate will be if a number does not converge after 30 iterations of applying the addition to the inverse.<\/p>\n<p>Here is my solution:<\/p>\n<p><img class=\"alignnone size-full wp-image-489\" src=\"https:\/\/danigguemez.files.wordpress.com\/2016\/10\/yosoy1.png?w=676\" alt=\"yosoy1\"   \/><\/p>\n<p><img class=\"alignnone size-full wp-image-490\" src=\"https:\/\/danigguemez.files.wordpress.com\/2016\/10\/yosoy2.png?w=676\" alt=\"yosoy2\"   \/><\/p>\n<p>We begin validating the user&#8217;s input as always with try and except inside a loop.<\/p>\n<p>We create a function that reverses <div class=\"post-limited-image\"><img class=\"alignnone size-full wp-image-500\" src=\"https:\/\/danigguemez.files.wordpress.com\/2016\/10\/yosoy3.png?w=676\" alt=\"yosoy3\"   \/><\/div>\n<div class=\"post-limited-image\"><img alt=\"\" border=\"0\" src=\"http:\/\/feeds.wordpress.com\/1.0\/comments\/danigguemez.wordpress.com\/477\/\" \/><\/div>\n<div class=\"post-limited-image\"><img alt=\"\" border=\"0\" src=\"https:\/\/pixel.wp.com\/b.gif?host=danigguemez.wordpress.com&#038;blog=115238226&%23038;post=477&%23038;subd=danigguemez&%23038;ref=&%23038;feed=1\" width=\"1\" height=\"1\" \/><\/div><!--more--> number in order for us to compare it to the original number.<\/p>\n<p>The for willdo one of three:<\/p>\n<p>Indicate that it is a natural palindrome if without any cycle repetition it is a palindrome.<\/p>\n<p>If the number after 30 or less loops becomes a palindrome, and<\/p>\n<p>If the number, after 30+ loops is still not a palindrome.<\/p>\n<p>The output is the amount of natural palindromes, the number of non-lychrell numbers and print the lichrel numbers, like this:<\/p>\n<p><img class=\"alignnone size-full wp-image-500\" src=\"https:\/\/danigguemez.files.wordpress.com\/2016\/10\/yosoy3.png?w=676\" alt=\"yosoy3\"   \/><\/p>\n<p>It was pretty fun to make. If you have trouble understanding what the program is supposed to do (like me) check out Ken&#8217;s video:<\/p>\n<div class=\"jetpack-video-wrapper\"><iframe class='youtube-player' type='text\/html' width='676' height='411' src='https:\/\/www.youtube.com\/embed\/KMDDoipS9H0?version=3&#038;rel=1&%23038;fs=1&%23038;autohide=2&%23038;showsearch=0&%23038;showinfo=1&%23038;iv_load_policy=1&%23038;wmode=transparent' allowfullscreen='true' style='border:0;'><\/iframe><\/div>\n<p>Thanks guys!<\/p>\n<p>Follow me on twitter <a href='https:\/\/danigguemez.wordpress.com\/mentions\/danigguemez\/' class='mention'><span class='mentions-prefix'>@<\/span>danigguemez<\/a><\/p>\n<p>Code on Github:\u00a0https:\/\/github.com\/Guemez\/TC1014\/blob\/master\/yo_soy_196.py<\/p>\n<p>Sources:\u00a0http:\/\/kenscourses.com\/tc101winter2015\/course-home-page-for-tc1014\/wsqs-tc1014\/wsq11-yo-soy-196\/<\/p>\n<p>#TC101 #python #KenCoursesChallenge #yosoy196<\/p>\n<\/div><br \/>  <a rel=\"nofollow\" href=\"http:\/\/feeds.wordpress.com\/1.0\/gocomments\/danigguemez.wordpress.com\/477\/\"><img alt=\"\" border=\"0\" src=\"http:\/\/feeds.wordpress.com\/1.0\/comments\/danigguemez.wordpress.com\/477\/\" \/><\/a> <img alt=\"\" border=\"0\" src=\"https:\/\/pixel.wp.com\/b.gif?host=danigguemez.wordpress.com&#038;blog=115238226&%23038;post=477&%23038;subd=danigguemez&%23038;ref=&%23038;feed=1\" width=\"1\" height=\"1\" \/>","protected":false},"excerpt":{"rendered":"<p>&#8211;Originally published at Fundamentos de Programaci\u00f3n Long time ago I tweeted that I was going to do all the proyects from a previous Ken&#8217;s course but it&#8217;s been a long time and I haven&#8217;t \u00a0posted a single solution. + It&#8217;s not that I haven&#8217;t done them, is just that I didn&#8217;t know which one to &hellip; <a href=\"https:\/\/kenscourses.com\/tc101fall2016\/syndicated\/yo-soy-196\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Yo soy 196<\/span><\/a><\/p>\n","protected":false},"author":8,"featured_media":481,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,4],"tags":[28],"class_list":["post-38016","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blogs","category-syndicated","tag-uncategorized"],"_links":{"self":[{"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/posts\/38016","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/comments?post=38016"}],"version-history":[{"count":5,"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/posts\/38016\/revisions"}],"predecessor-version":[{"id":40699,"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/posts\/38016\/revisions\/40699"}],"wp:attachment":[{"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/media?parent=38016"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/categories?post=38016"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/tags?post=38016"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}