Sunday, December 30, 2007

My programming sucks

Despite being able to compete in the finals in two separate programming competition (DGX 2001 and PanaGeek 2007), I can't help but thinks that I actually do suck in programming. Allow me to explain.

You see, programming is not just about writing error-free codes. It's also very much about solving the problem using the most efficient way. Computers nowadays may be fast, but there exist problems that could that ages to compute even on the fastest of modern personal computer. Besides that, your code must also look simple. Like they say, the difficulty is not on solving the problem, but solving it and making it look simple at the same time.

To claim that you are a good programmer, you need to be exposed to many different paradigms of programming like functional programming (e.g. Haskell, ...), concurrent programming (e.g. Erlang, ...), logic programming (e.g. Prolog, ...) and etc. For myself, I have limited experience with these kind of languages. I'm currently trying to learn Haskell myself, which is a functional programming language. However, my Haskell journey is far from complete.

If I'm really that good, well, I should be:
  1. Working for Google.
  2. Writing complex 3D games with millions lines of code.
  3. Compete and win in eGenting programming competition.
  4. Compete and win in ACM programming competition.
  5. Solving algorithmic problems in topcoder.com in record time.

Well, all that hasn't happen yet, even though those are some goals I'm trying to achieve. I mean, who wouldn't want all that? All programmers would like to have some of these in their resume, no?

Friday, December 28, 2007

I'm PanaGeek finalist?

Just got called this morning, informing me that I was selected as one of the top 20 finalists of PanaGeek 2007, along with Lim Fang-Ying and my lab partner Ho Wing Teng.

Glad to know that I was given a chance to compete in the final round. At the same time, I'm also sad. My dear friend, Wing Teng was recently warded into Hospital and just had an operation. His condition is now stable. The bad news is that he may need to stay in the ward for 2 weeks or so. I hope the officials of PanaGeek can made special arrangements for him, or extend the date for the final round. It's important that everyone can compete on equal grounds. I believe no participants would like to win, knowing that he/she won because someone couldn't come that day :).

Monday, December 17, 2007

Panasonic PanaGeek Competition 2007

I attended the competition on last december 15 2007, Saturday in PJ Hilton. Beautiful hotel and nice food aside, the most interesting thing is the question itself. Here's my take on it.

The questions are slightly more difficult than what I anticipated. Consequently I did not prepared well. Could have used some study on operator precedence and etc. But what the hell...

The questions are broken into 3 sections. The first section aims to test your general C/C++ knowledge. If you can't get pass this, you probably won't do so well in the last 2 sections. In the second section, you have 2 major questions. For the first you get a question on arbitrary multiplication (something I've written before, to solve a n-factorial question). Basically you understand the code, and you answer questions based on it. For the second question, you are shown a flowchart of a hotel room vacant search problem, and you answer a few objective question on it. For the last section, there is 2 problems. For each you are expected to write your solution on the question paper itself. I wish I have slightly more time to complete the shortest path finder problem though *laughs*.

It was a great experience. I enjoyed every moment of it and if I did not win, I'll try again next year.

Wednesday, December 05, 2007

You can't change your personality

Personality, like they said, determines how people think of you. If you constantly be nice to people, people will have a great impression of you (But a minority of them might labeled you as someone who can be taken advantage of). Be mean to your friend just once, and you'll be forever condemned in their eyes (But most of them will labeled you as a selfish friend). This is not at all unreasonable, as your friends are always right (sort of). You are not always wrong though, but what you see as something quite reasonable and fair, your friend may not see things the same way. That's OK though, as your friend is right, and you're wrong, mostly.

From my point of view, one can certainly change his personality, and thus, behavior (People always do). However, when you change, you risk offending your friends. For example, you used to be nice to people, you always helped them with their responsibilities, at the expense of your own time, never mind you have to stay overnight to do it, risking the fact that you may not have enough time to complete your own work. One day, when you decided that it is a foolish thing to do, and you break the behavior. The problem with that is, people are not expected to have a radical (It's considered quite radical, actually) change of behavior. If you do, people could come up with various wild conspiracy theories about why you don't help them and most of the time the conclusion that they have come up with will not be in your favor. Precisely why, is totally beyond me. Perhaps that is how the human brain works. They're designed to be suspicious and always think of the worst scenario (Though I was told that girls has an extreme version of this ability). This ability, is useful in the sense that, it allows people to prepare for the worst, such as deserting friends that has lost its usefulness. Not everyone do that, but some do (though some that do, without realizing it).

Now, what happened when you have a change of behavior that do not benefit your friends? Various things happens. From now on, you will be suspicious of everything. Even things that are not of your fault. You are of course expected to live with that, since you are the one that initiated that change of behavior. And you can't blame them, since in theory, your brain works the same way, just that in this case, you are the one that has changed, not your friend.

In spite of all this, should you care about all these complexities? Probably not. All you have to do, is determine what is the best you can do to yourself first. This is not selfishness, this is called self-interestness. Unless of course, by valuing yourself more than others you harm a great number of people. In which case you should probably sacrifice yourself like Jesus does. Don't worry, as you would surely go to heaven (The bible says so).

I for one has got tired of trying to be someone I'm not. I'm not a stunt man. I don't pull stunts in real life. Stunts like helping people finish his assignment when I have more important stuff to attend to. It's not a lame excuse to bring harm to my friends. Rather, it's a hard conclusion I've come to after I've done a full reality check on myself. And the reality is indeed a cruel one. The question is, is the world becoming more cruel and bleak? I think not. It's merely becoming more matured. Likewise, a matured person tends to not take things likely. They think twice before jumping into conclusions.

Sunday, December 02, 2007

The difference between help-needer and guide-needer and etc

Continuing from my last post, I figured that I need to clarify a few important points before I'm being classified as someone evil on the same league as Osama Bin Laden.

1) I don't help people, does not mean I don't guide people. There's a world of difference between people who expect you to do his/her entire final year project/assignment/tutorial and people who just need your guidance. I have my respect for people who just need some guidance. I however, have ZERO respect for the other. What for, since he/she expect to gain something without doing anything.

2) I still do freelance. Well, despite all that, I still do freelancing. I just don't do charity. But sometimes it's a bit hard to difference between the two. Let's start with a few examples. "I want you to do an e-commerce web site that can buy/sell books. Like Amazon.com lah. I will give u RM 100 to do it. Want ah?" - This is a charity. "Eh.. can you help me do this assignment a? I spent you eat lo..." - This is also a charity. "Can you develop a cinema ticketing system for us? We (Company XXX) will pay you RM 5,000 for this. - That is freelance (If it conforms to market price).

3) My purpose is not to offend people. I don't blog to get attention. Or to blog with the intention to offend weaker people. To me, that is not my purpose. Instead, this is their choice, their own doing. That said, NO one wish to be weak. Well, that's mostly true. HOWEVER, like the saying goes, "everyone wants to go to heaven, but no one wants to die to get there," the problem is, every computer science students wants to be god programmer. But ask them to spend 11+ hours everyday infront of the computer screen doing programming exercises, reading programming techniques, reading books on new programming languages, analyzing/modifying other people's millions lines long code and etc, they say you must be crazy. The thing is, every rewards comes with a price. If you pay the price, you reap the rewards. It's as simple as that. If you pay peanuts, you get peanuts. That's not cruelty, that's reality.

Sunday, October 14, 2007

My UPS battery changing experience

My UPS (Uninterruptible Power Supply) has went dead for quite some time. I thought the board just went dead or something. Turns out the battery is the culprit. I went and bought a Yokohama 12V 7.5AH battery for replacement. Now, it went back up.. just in time for a lightning raining season. Yippie!

Friday, October 12, 2007

The day the network went down


This is what happens when the network goes down.

Thursday, October 04, 2007

Eventual justice theory and Reverse psychology

http://thestar.com.my/news/story.asp?file=/2007/10/4/nation/19069901&sec=nation

The above story is about a young blogger land herself in trouble because she blog about an incidence where by her fellow students cheated during a test and she claimed that the teacher who knew about it did nothing to stop it. She was demanded to remove her blog entry.

My thoughts? Why bother? Cheating does them no good. If you know reporting it does you no good as well, then why bother making a fuss out of it? It's nice of what she did. But in some cases, justice may not prevail. Even thought it eventually will. Someday those who have cheated may regret about it. And that will be the times justice served them right.

EDIT:
The important issue to remember here is that, we should NOT condemn her for what she SHOULD or SHOULD HAVE done, but rather, why she is treated, the way she is treated when she has done nothing unlawful or wrong. If someone did something unwise and get punished, and he/she did something within the boundaries of the law, one must question the intention of the punisher, no? *hint hint*

Friday, September 28, 2007

Tuesday, September 25, 2007

Sudoku verifier using bit fields

A while back, a friend of mine had this idea of writing the most efficient sudoku verifier.

So I thought I would give it a shot. And this is what I've come up with:

char VerifySudoku(char grid[81])
{
   unsigned int bitFlags = 0;
   unsigned short buffer; // to speed up things
   char r, c;

   for (r = 0; r < 9; bitFlags = 0, ++r)
   {
      for (c = 0; c < 9; ++c)
      {
         buffer = r/3*3+c/3;

                     // check horizontally
         bitFlags |= 1 << (27-grid[(r<<3)+r+c])
                     // check vertically
                  |  1 << (18-grid[(c<<3)+c+r])
                     
// check subgrids
                  |  1 << (9-grid[(buffer<<3)+buffer+r%3*3+c%3]);
      }
      if (bitFlags != 0x7ffffff)
         return 0;
   }
   return 1;
}



Normally, one would have 3 loop one to scan horizontally, the other to scan vertically and lastly one to scan the 4 subgrids. If any one of that contain duplicated number, the grid is invalid. But here, one is enough. I scan 3 of the criteria in one single loop. Nothing fancy here, just the work of a boring soul. Haha...

Monday, September 24, 2007

Writing the shortest code

If you have not heard about the web site http://golf.shinh.org, a short introduction. It's a site with a list of programming problems, and people are expected to submit their shortest code to solve the problem with their language of choice.

Just to have some fun, I participated in the "FizzBuzz" category. Basically, all you have to do is: Print integers 1 to 100, but replace multiples of 3 with "Fizz" and multiples of 5 with "Buzz" and multiples of both with "FizzBuzz". Simple right?

Shown below are some of my solutions. How short can you go?

PHP: while($i++<100)echo$i%3?$i%5?$i:'':'fizz',$i%5?'':'buzz',"\n"

C: main(i){while(printf(i%5?i%3?"%d\n":"Fizz\n":"FizzBuzz\n"+(i%3?4:0),i),i++<100);}

This take advantage of ternary operation ?: in C. Also, look at how we can "offset" a static string by using an integer. For example let say u have a character array "Hello" in C. printf("Hello"+1); will print you "ello" on the screen. Pretty nifty no?

eGenting programming competition 2007 experience

On the 22th of September, me and my friends participated in this year's programming contest. In my case, I managed to complete (or almost) 2 questions. The Financial Statements (report) and the Air Polution Monitor.

For the first question, I (believe) I almost nailed it but with mistakes here and there nonetheless. The code that I wrote was also extremely inefficient. It was a pain to write a program without a computer or with a decent IDE like NetBeans. I guess my programming has got rusty by being overly dependent on IDE.

For the forth question, I did slightly worse than the first question as I got some of the concept wrong. For example, for the file reading part, I read the wrong function (I used a binary file reader) and thus it won't work. What an idiot!

As for the other 2 questions, well, they are blank, as I had ran out of time.

Overall, I feel that the questions are getting *slightly* easier as the year goes by, but still considerably tough for most students. Either that, or my skills are improving. Haha!

For those who are interested at looking at the questions, heard over to http://www.searcy.com.au/comp_epilogue_2007.html. The solution is there as well.

If nothing comes out of it, well, at least it was a great experience.

Thursday, September 13, 2007

First post

You know some people are willing to sacrifice anything just to have the chance to say "First!" in a forum or commentary section? Well, I don't have to, since this is my own blog :).

Well, this is my first blog post, so let me introduce myself.

My name is Simon Lim Hao Wooi, born 1984. I'm currenly Year 3 student at the University of Tunku Abdul Rahman, studying computer engineering. Think of it as a little bit of Electronics and computer science.

I started my interests in computer by doing some web design and web-based scripting. Thus, one of the first language that I learned happens to be ASP. Well, technically ASP is not a language. But at that time, VBScript is the only way you could use to do ASP. I was quick to switch to the "open source" side however, by learning PHP and subsequently fall in love with it. I never look back.

Like all things, people change. Soon after I got bored of doing plain old HTML page (It may be generated by ASP, but it's still plain old HTML), JavaScript came along and changes everything. All of a sudden, you could made all sort of cool, interactive stuff with a plain old HTML page. The funny thing is I've been playing with JavaScript for so long that it would later be collectively called AJAX, along with the advent of XML and the rise of asynchronous function calling.

Later, I would start moving myself out of web development, and dived myself into the world of software development. That's where I started playing with C and C#. That's also the time I introduced myself to dotNet. Slowly but surely, I realized that programming is like like writing poem. Without knowing the algorithm, you don't know what to write in the first place. That's why, nowadays I like to solve hard problems using programming. I begin visiting topcoder.com for interesting problems to solve. After all, what is so fun with programming if you are not solving any problem?

Currently, I am working on my AI project entitled "Machine Learning Approach to Real Time Unconstrained Multiple Vehicle License Plate Recognition". And 1 more year before I graduate. So that's all about me for now. And thanks for reading.