Sometime last year I bought Chris Pine’s Learn to Program book. I read a little bit of it, then put it down. I was still so new to Ruby then, and all the problems seemed extra difficult. Once in a while I’ll take a look at it, but it’s a little bit hard for me to code from a book, when I could go online and find hundreds of exercises to practice with. There was one problem in particular that stuck with me, called 99 Bottles of Beer. The exercise said to write code that would print the lyrics of that song. I had to look them up because I wasn’t familiar with them. Now, last year I looked at that problem and thought “I can’t solve it. I don’t know enough yet”. For whatever dumb reason I never attempted it after that, but still thought of that problem from time to time. A year later, on this day, I solved it. It happened in the shower, where all of my best ideas come from. It just suddenly came to me! People talk about this exact sort of thing: sometimes you can’t figure out a problem while sitting in front of it for hours, racking your brain for a solution. Apparently your brain is constantly working, even in the background, figuring things out. Sometimes I couldn’t sleep at night for this reason; my mind was constantly racing thinking about ways to solve my problems. I’ve since learned to stop that, so as to not exhaust myself. Today was different. I woke up late, and was bored of what I was doing and needed a break, so I went to do something that always makes me feel 100%. It just hit me so quick when the problem popped up in my mind: I could set a counter to start at 99, then enter a loop that will print out the appropriate lyrics for the song, while subtracting 1 to account for the number of bottles after the initial amount. I will decrement the counter by 1 until I reach 0, at which point I exit the loop and that’s it. That’s literally all it is. I’m sure there are a million ways to do it, but for me, this is easiest for me understand. I can glance at it, and understand what is happening at each step. It just flows, at least for me. I’m proud of myself for FINALLY solving it. It really gave me that boost that I needed today. I am learning.
Day: September 5, 2019