Post Attack Part 1: Homework! Homework everywhere!

Part 1

Hey, my precious reader(s). It's been a long time since my last update here. Relieved to know I'm still alive? Relax, it's just a couple weeks, I've seen longer. For instance, Mike Shinoda finally updates his blog after a couple months of silence, and the news is very very exciting - Linkin Park is releasing a new album this summer! And they're gonna go old school and play their very first album - Hybrid Theory in whole in the Download Festival summer! I'm so excited. "Okay, they may be some good news, but that has nothin' to do with your disappearance, man." I hear you say. Alright, I'm sorry, I've been slacking off on the updates, but that doesn't mean I didn't give that a try.

I've got a lot of non-finished blogs in my draft folder, but I never got the time to finish any of them. Why? I'd been spending most of my time on my homework and finally done last week. To make it up to you, I'm gonna publish a series of blags talking about what's going on in the past few weeks.

Let's start by talking about my last week first.

On Monday, I submitted the simplified Candy Crush assignment. If you had read some of the blags I wrote earlier, you'd already known I was doing this assignment quite slowly. I was still having all kinds of fun when the others'd already started and had been making progress. I'd done nothing physical or actual work at all, some would say. I'm not bragging but I'm quite confident in my coding skills. Every time it's either I can't figure out how to write the code or I can write code with 90%+ accuracy. Therefore, my debug time normally is very short. Due to laziness and confidence, mostly I just thought about the assignment and wrote some code on my cellphone using 920 Text Editor the whole time. But this piece of shit still took most of my time away. I've already been nice when I said it's a piece of shit. In that class, we had to finish a simplified Candy Crush using Fortran and COBOL. Yeah, we had to write the program twice, not once, but twice ... and with a report discussing the difference between these 2 programming languages and how you designed your program. They also added another ridiculous request: any use of for...loop, while...loop, if...then...else were all forbidden, except if...go to label. They gave us a specification document to "guide" us through. But until now, I still think the specification document is very unclear. After I had spent a whole week "decoding" the words of the specification document, here's what we had to do:

Before we start, there're a couple of background information you need to know first,


  1. They called the board you could swap candies the "Wall", and there was a "Roof" above the "Wall" to store the candies about to fall onto the "Wall" when some of the grids on the "Wall" were empty. So we had to read a file storing data like the "Roof" dimension (no. of rows and columns), "Wall" dimension, the candies on the "Roof", a target score, and the positions of the 2 candies you'd like to swap. The "Wall" was supposed to be empty. For instance,

    ----------
    |314152|
    |653532|
    |346264|  "Roof"
    |333252|
    |411334|
    |262623|
    ----------
    |xxxxxx|
    |xxxxxx|
    |xxxxxx|  "Wall"
    |xxxxxx|
    |xxxxxx|
    ----------

    This is an 6 x 4 "Roof: and a 5 x 4 "Wall", where the 6 numbers stand for different colors and x means an empty grid.
  2. Then the candies on the roof would fall onto the "Wall". And the swapping should be done next. Throughout the whole game, you could only do one swapping, and the program should count the no. of candies falling from the "Roof" after the swapping as the score.
  3. There were only 3 types of matching shapes: Straight, L - Shape, T - Shape                           

  4. A Straight Matching with 4 or more candies would form a super candy called "Stripped candy".
       An L - Shape Matching or T - Shape Matching would form another super candy called "    ".
  5. A matching which didn't involve any super candies were called a "Normal Matching".
    Of course, A matching which had super candies involved were called a "Super Matching", and its priority was higher.
  6. A super matching with a stripped candy would vanish the whole row, while a       candy would vanish the 8 candies around the candy, and itself. They called these kind of operations the "Explosion".
Is it clear? Definitely not, besides, it's just my interpretation so far. I could guarantee we both are having the same questions in our minds, like "How the program should operate?", "If there're multiple matchings, what should we do?", "Only straight, L-shape, T-shape? Then how about a cross pattern?", "When there is a super matching, should I do the explosions or refill the candies of wall first?"

Well, according to the specification, the program should scan the grids "from left to right and top to bottom", poor word play. They meant we should scan the rows from top to bottom, and for every single row, we should scan from left to right. If the program found a matching while scanning, it should take action. After discussion with the TAs, the program didn't need to take care of cross-shape matchings, just count them as L - shape or T - shape whenever necessary.

And for the "Roof" part, when a column of the "Roof" was empty, we had to renew the column by reference to the original "Roof".

So here's what I did.

  1. I mapped out all possible patterns of L - shape and T - shape matchings first. There were totally 8 of them. Then I wrote "subroutine" (i.e. subprograms) to detect these patterns for every candy on the wall. And then I was informed cross-pattern matchings were not a necessity, so I had to rewrite and delete a lot of my code (especially the labels), which occupied me a lot of time.
  2. Then I studied the examples from the document trying to figure out explosion first, or renewing the wall first while writing other subprograms which didn't involve these kind of operations.
  3. During the Chinese New Year Holiday, I finally figured out these routines which could crack all the test cases given:

    (a) Read the data from the file

    (b) Drop the candies from the "Roof" to the "Wall"

    (c) Supposedly there should be no matching patterns, so we do the swapping. The program starts to scan every single grid.

    (d) Check out the grid to see if a matching is found.

    (e)If it's a normal matching, let it go.

    (f) If it's a super matching, vanish the candies and mark position of the super candy.

    (g) If the super matching pattern can create a super candy , create it.

    (h) Repeat (d) to (f) until the last grid.

    (i) Scan the grids again in a similar manner, but this time, we do normal matchings.

    (j) When there are no matchings left, do the explosions.

    (k) Let the candies fall from the "Roof" and count the score.

    (l) Repeat (c) again until no matchings are found.

One day after the Chinese Year Holiday, I finally finished the whole program in FORTRAN, and I already caught up with most of my classmates. The next task was to rewrite
the whole thing in COBOL. COBOL was really not suitable for the assignment at all, some people even jokingly compared it to "playing tennis for 10 hours with a table tennis racket". I was very uncomfortable with the format and structure while coding. It was more like writing an essay than writing an actual program. I literally hated it. And after the rewriting process, I'd got 9000 lines of code.  And I hadn't figured out how to read the file and produce a file using COBOL yet. More importantly, I only got 30 minutes left to debug my code. Surprisingly, my program worked at the first try of compilation but produced wrong results (It's still an achievement!), 30 minutes were far from enough to find what was wrong with my code. So I focused on how to read the inputs from a file, which I succeeded. I immediately submitted it but it'd already 5 minutes past the deadline. Nevermind, and why?

Oh! I haven't told you that? To show some sympathy or just because they were sick of answering question after question about assignment in the newsgroup, they gave us an easier choice. We could simplify our programs to merely vanishing matching candies, throwing all those super matchings, special candies stuff away. But if you stick to the original assignment, you could get 50 marks more. I thought I'd already come so far, so I stick to the original one. Many of my friends had already switched, they should be ashamed. It still hurt a bit that I couldn't finish the COBOL program, but I could be sure I would get higher marks and I'm REALLY SICK of COBOL (for now).

After the deadline, they have already released another assignment. This time we have to use Ruby and Java. I haven't read the details yet, but I heard it's about writing a Connect-Four program in Ruby and translating a piece of Ruby code to a Java one, sounds easy (I'm probably kidding).

After that ridiculous assignment, I have to write a composition about myself for an English class. It's mostly about my childhood, high school life, college life and expectation of my career. After 4 days with out sleep, I still manage to finish the composition in an afternoon. Why is it so rush? That's because I had to find my partner Jeffrey to record an interview basing on this piece of composition at night. His piece of composition is way more interesting than mine. After all things are done, I go back home and have to start another assignment in my Computer Organisation Class, which is due on Thursday in the afternoon. I have 3 days to do it, but actually it's not.

Why? On this killer Monday, I've also accepted a job teaching maths to some primary school kids. Therefore, on Tuesday, I have to go to Kwun Tong and took the notes first, and then went back to CUHK to join the English Table, which I really regret I did. It was the worst English Table ever, cause the theme was VELENTINE's DAY! DAMN! And I had no idea why, the professors in my English classes also shown up. If I was picked to give the impromptu speech this time, I would be so dead. Luckily nothing happened, but still it was the most boring English Table ever. I don't wanna talk about it anymore so lemme briefly explain what I've done for the rest of the week and call it a day, how about that?

So on Wednesday, I go to the primary school to teach those kids Maths. It's not very fun at all, but I'm okay with that as long as I get paid. So moving along, I spend the whole night to finish the Computer Organisation assignment and submit it on Thursday. Wow...you finally can catch a break? I hear you asking. The answer is NO. I also have to write a German dialogue about eating in a restaurant so I can submit it on Friday morning. And then I can catch my break, on Valentine's Day.

This week has been brutal, I can honestly say, all those "college is about having fun, y'all", "yeah, studying for your open exams is hard, but you can chillax and do whatever you want when you enter into college, man" you've heard before, they're a bag of lies to me.

You may argue,"Dude, you've got your Chinese New Year holiday to finish your homework but you didn't, you deserve that." I may do, but a part of me doesn't agree. I admit, half of the time I was going out having fun and getting red packets. But I was also writing code and finishing my homework for the other half. And lemme tell you, I only got 7 days of holiday, which is the shortest Chinese New Year Holiday in my entire life. So I think the man has suffered enough. You cannot imagine how relieved I am when all thing's done. The feeling of everything works out is totally awesome!

Now that we're on the subject, let's talk about something happier and go back more further to see how much fun I had been having before all these miserable things sneaked up behind me and made everything miserable. See you in a minute!

Kev

(Update on 6/5/2014: There will be no part 2, 3, 4 ... whatsoever, my attack failed, sorry.)
Post Attack Part 1: Homework! Homework everywhere! Post Attack Part 1: Homework! Homework everywhere! Reviewed by Kevin Lai on 7:38:00 PM Rating: 5

No comments:

Powered by Blogger.