Hi! This is by far the hardest WSQ I have done. It consisted of creating a Lychrel Number detector but also inform about natural palindromes and Non Lychrel Number. So, to understand this, I guess it’s important to introduce the concept of a Lychrel Number. But to do so, first we have to understand what is a palindrome. A palindrome is a word or number which can be read backwards or normally and says the same, for instance, 12344321 is a palindrome, so is dad. Well, a Lychrel Number is one that does not become palindrome after several iterations of the addition of the reverse. The first known number to be known as Lychrel is 196.

So now that we know what we’re talking about, I’ll talk about the coding process. At first, I had issues sorting all that should be done and how would I do it. But after creating functions and using loops I managed to find the basis of the subject. The first function I created was to reverse the number, I found a nice formula used to reverse a number in this site: //http://www.programiz.com/cpp-programming/examples/reverse-number. Afterwards, I created another function for the Palindrome, which resulted complicated since I had to create another variable so the Palindrome detector wouldn’t output: “I found a Lychrel! It is: 1894789431487384710752”. This was my first issue, solved by a new variable. Also since long long would not hold so many values, I had to implement the BigInteger class, Ken’s video has a nice explanation about it. Finally, I created counters for each type of number, and with ifs I determined how they would be classified.

 

And without further ado, here’s the code:

https://github.com/CarlosGallegosT/Codes007/blob/master/lychrel.cpp

Thanks for watching the code, it was a real challenge.

My reaction throughout this coding:

 

                                                       

Image Source: https://www.reddit.com/r/AdviceAnimals/comments/23ruxk/any_programmer_would_agree_that_this_is_quite_a/

 

CC BY 4.0 Yo Soy 196 #WSQ11 by Carlos Gallegos is licensed under a Creative Commons Attribution 4.0 International License.