As my lecturer drones on, I have bigger problems at ha
nd - literal problems. Google Code Jam 2015 had just started, and I had solved a ll but one problem. It isn't a particularly daunting question to most, but to me , it is monumental. The Infinite House of Pancakes was a problem that I haven't been able to solve in the past 16 hours, and I am determined to do so within th e 6 hour deadline that loomed over me. My teacher finishes his lecture on Esters , and passes a worksheet around. I take one, and immediately zone out as I ponde r the real question at hand. Okay. So let's take a brute-force approach to this. Exhausting all possibilities , then. But that would be impossibly large, considering there are at least an ex ponential number of different possibilities. That won't work. I'll need somethin g faster. Much faster. I subconsciously reach for my pen, and start spinning it around. Now that I think about it, pen antics actually help me think better. So, no brute-force. Now I need to exhaust some of the material I'd read up on by myself - algorithms and all that jazz. Let's start with something fairly simple - what data structure will help me solve this problem? I visualize putting stack s of pancakes into queues, heaps and trees. Hands flailing, I put all the data i nto structures and put them into the structures I've conjured in mid-air. My ben chmate stares at me with an inquisitive expression. I look at him and shrug. I g uess it's not so obvious that I'm visualizing things when they're just in my hea d. I go back to thinking about data. I push stuff around, sort, and search. Nope , as far as I can see, none of the structures work. It seems I will need somethi ng a little more complicated. I guess that's what I should expect from Code Jam anyway. The school bell puts me out of my trance. I put the worksheet into my ba g while still pondering the question. Now, I model the problem as a graph. My Computer Science teacher walks into the class. I notice him, greet him, and then go back to my question. I take my pen a nd start mapping out the question. The problem as a graph is surprisingly large, and it takes quite some time for me to put down in ink. I look up to the board and notice that we're studying binary trees today. Thankfully, I know my binary trees, so I can continue on my problem without any risk of falling behind. As I complete the graph, it hits me. A breadth first search algorithm could easily co mpute the shortest path I needed to solve the problem. Without missing a beat, I boot up my laptop, and proceed to code up my program. The window I'm coding in suddenly freezes. Times like these are when I wish I ha d a faster computer. Slightly frustrated, I close and restart the window, retrac ing my keystrokes and replicating the program I'd been forced to erase from memo ry just a moment ago. Finally completing the program, I impatiently wait for the test file to download so I can test my code. Out of the blue, my teacher shoots me a question on the topic the class is discussing. Thankfully, I know the mate rial, so I answer. The teacher smiles and looks back to the board. Close call. B y then, the test file has finished downloading. I make some slight modifications to the code, and with fingers crossed, execute the code. The output isn't corre ct. I guess I had to expect at least some bugs in the code. I look through the Java I wrote, running my eyes over and over the same blocks o f characters, and finally I catch a block that seems a little off. Correcting it , I press Run. The output is correct this time. I feel my heart jump a little. I quickly go over to the Code Jam website, and submit my code. The site evaluates my code, and returns a bright green CORRECT next to the problem name. I smile t o myself. To the outside world, I've solved a simple brain teaser. But to me, I just grew as a person. I've learnt how to apply, in real life, something I've le arnt in a classroom, something I've learnt while endlessly poring over Thomas Co rmen's "Introduction to Algorithms" and something I've learnt in those tens of h ours of Coursera videos. I've harnessed my knowledge into practice. And if that isn't one of the most satisfying things in the world, I don't know what is.