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:
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! 😀
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:
And lastly, this is how it worked: