The longest hours of Algorithm and Programming I Assignment.

I’ll just write my story here.

Previously, i was going to write it on my code. But hell, no!

January 1st, 2016. 16:49.

This morning (git commit on my computer timestamped at 6:49 AM –what a coincidence–), i finished refactoring lastSpaceBlock function (the funciton to find the last filled pattern). Previously, i check the selected message with the actual message. Because comparing string need to call another function, i decided to leave it and go with index accessor to find the last filled pattern. Solved, Commit!

Everything was fine here, but the pattern still printing spaces when the next pattern are empty. Still 19 hours remain, no worries!

To solve the space problem, i prefer to use a function which compare the lastSpaceBlock result with the block index. The problem is, lastSpaceBlock only return a single index location. Each pattern line are unique, and this function messed the pattern result when a block have fully spaced line pattern. At the end, i use the struct method and convert the lastSpaceBlock function to the struct type.

I create the struct to hold the location of filled pattern for each pattern line in an array of five integer. Then the lastSpaceBlock return the array. Everything seems fine here. I leave the code at this state because I had to do the human thingy.

A couple hours later, i return to the code world. Opening Sublime, and SourceTree. I see my own comment on the code, and figure out what to do to solve this space problem. Everything happened so fast at the moment. My brain think faster than my hands typing.  I create the “switched” loop (i got the name from this paper) and a for inside it,. The switched loop only checking the 1st, 2nd, and 5th line, because the other 2 lines are all filled.. I’m so confident to check the result, but I was wrong. My code fail. The pattern still printing the unneeded spaces.  Then i’m trying to initialize the struct array. But it’s solve some case, but it’s still wrong.

Then I replace the for loop inside switched loop with while with a help of a status variable (to break the loop when the pattern are filled). Then I replace it again with do while loop. After that, my code seems perfect. I couldn’t imagine it’ll be wrong again. I press the Ctrl + B button, the Build Command on Sublime, and inputting the acse to the console. But the space are still there. What’s going on?

I try to change the conditional check inside the for loop, but it’s still wrong. I then decided to discard the code rewrite it. But still no luck. So much hour wasted to figure out that the problem were lies on the status variable.

Previously, i initialize the status variable at the beginning of the function. I never thought about reinitialization at each loop until somehow my eyes catch the int status = 1; line. Then i write the status variable reinitializatino on each for loop, and voila! Works like a charm!

The clock point on 16:49, 10 hours after my lastest commit. So many stupidities happen here. After the moment when my brain think so fast, it’s stuck like a snail. Resulting in many innocent hour wasted for this. But still, this is how you learn. This is the learning curve.

You aren’t noob, just less experienced.¹

Looking back for the aim of this assignment, my lecturer gives perfect name for it, the name itself describe it so much. “Tugas Masa Depan” (The Future Assignment, ed). Even further, the tagline make it complete. “Untuk masa depan yang lebih baik” (For better future, ed).

I saw many things happened from this assignment. Not only on my own self, but also at the other. There’s someone who were really passionated with this, and there are the other, who lost his confident.

This assignment prove that time management are the most important things in our live. The faster you finish this, the more you able to do other things. The right amount of time you allocate for this, the result are just “right”. At the other hands, those who can’t manage their time will ended up suffering, walking with the shadow of remedy.

Thank you, for the lesson, Mrs. lecturer.

Further Reading:

My TMD Git Commit History –

Efficient C Programming:

Efficient C/C++ Coding Techniques –

¹Well said, Ben.