Lycherels: Yo Soy 196!

This week I worked with a problem called Yo Soy 196, which consisted of receiving a range of numbers from the user and determining the ones that were natural palindromes, non-lycherels and lycherels.

I didn’t know the definition of a lycherel number, so of course I started by reading about that:

https://en.wikipedia.org/wiki/Lychrel_number

After I fully understood what I had to do, I started writing my code. When I was done, it had a problem because it ran, but it displayed some numbers as lycherels that were not actually correct. I spent a lot of time trying to figure out why, and I asked several classmates for help. The person who at the end made me see my mistake was a fellow computer science student who took Ken’s class last semester (you can check out his blog here). Turns out, I was not initializing to zero my variable times every time it changed number, so the next one took the last value it got in the while loop 😦 .

I corrected it and it finally did the right thing! 😀

lycherel

As you can see, I used the range() function in my for loop. It was my first time using it, and I learned how it works from this page:

http://pythoncentral.io/pythons-range-function-explained/

And lastly, this is how it worked:

lycherel_run

 

One thought on “Lycherels: Yo Soy 196!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s