Category Archives: Personal Life

End of Algorithms 1 class by Sedgewick and Wayne

So the Algorithms 1 class by Professors Robert Sedgewick and Kevin Wayne of Princeton on the Coursera platform just ended. I just made my second of three attempts on the final exam, scoring 18.31 / 20.00. I may yet make another attempt next week as everything officially closes only on 30 September 2012. It’s been an amazing experience and I learned way more than I expected. Some thoughts:

  • I found that I’m pretty strong on practical programming. I could complete all of the programming assignments with not much trouble, and ended up spending a fair amount of time on the forums helping others out with their programs too. I only struggled somewhat when implementing the optional extra optimizations that the professors suggested which are not graded. This mostly involved doing the same thing with half the memory or less, or cutting running time down drastically. For example, the toughest timing trial of the collinear points assignment gave you a maximum of 10 seconds to solve the problem. My first attempt came in at just under 7 seconds, and after much agonizing I got it down to just under 3 seconds. The very best students were able to get it down to just under 2 seconds.
  • However I am terrible on the theory. I blame that on a lack of solid grounding in mathematics. I really suck at calculating things like the order of growth of running time for different algorithms or the minimum and maximum heights of different tree-like data structures. This calls for a good grasp of discrete mathematics. I’m also bad at internalizing geometrical principles, so assignments like collinear points gave me more trouble than the supposedly more sophisticated A* algorithm we used to solve the 15-puzzle. I’m currently signed up for Sedgewick’s Analytic Combinatorics class which runs next year but I’ll probably flunk that one.
  • This class really thought me how beautiful some algorithms are and how you can achieve so much in just a few lines of code. At heart, they’re all about pure logic so it’s possible to even describe them to people with no programming knowledge whatsoever. I also think I finally managed to get the hang of recursive functions while doing the Kd-Tree assignment. I’ve always had trouble visualizing them before.
  • I also learned how very limited even the powerful computers we have available to us today are. As a science-fiction fan, I’ve always taken it for granted that one day, perhaps sooner than we expect, we’ll be able to simulate sentient minds and even whole worlds inside computers. Unfortunately, even the lowly 15-puzzle is enough to make modern computers struggle. It’s pretty humbling. As Sedgewick likes to emphasize, while we can always look forward to ever faster computers in the future, it is even more certain that the size of the problems we need to solve in the future will grow faster than our computers will become more powerful. As we can’t rely on ever more powerful computers to do the work, we must instead design ever more clever algorithms.

Anyway, Algorithms II starts up in November so I’ll be back at it pretty soon. In the meantime, I should have a little extra free time.

A logical puzzle

I’ve been remiss in writing for this blog because I’ve been busy with the courses I’ve been taking on Coursera.org. Currently I’m taking both Introduction to Finance and Algorithms. The Algorithms class is particularly challenging for me and involves significant work because there’s a programming assignment each week. It’s taught by Robert Sedgewick of Princeton, who is something of an authority in the subject. Interestingly, Sedgewick’s own doctoral thesis advisor was Donald Knuth, who is of course a legend in computer programming circles.

Anyway, just for fun, here’s a logical puzzle from a recent assignment for you to ponder over. I’ve converted it into a puzzle to make it more accessible, no actual programming necessary, but the essential logic of the problem remains the same.

Let’s say that you’re working at a booth of some sort and you have only one task. A client will come up to your booth and announce a number. Call this number k. This number represents how many items you will need to hand back to the client at the end of each task. The client then starts handing you items, let’s say they are beach balls, each of which are uniquely identifiable, one at a time. The client never tells you how many balls there are in total. He or she just starts handing them to you, one by one.

At some point, the client will announce that he or she has finished handing over balls. Now your job is to return k balls, selected with uniform randomness from the balls you were just given, back to the client. Sounds easy right? But here’s the constraint. Your booth can only store k balls at maximum. That is to say, you can only hold as many balls at a time as the number of balls you need to return to the client at the end of the task. You may choose to keep or discard any ball but once you choose to discard a ball it is gone forever and you can’t ever get it back.

So how do you ensure that you can select k number of items with uniform randomness, out of a pool of potentially many more items, while being restricted to only holding k items at a time?

Assorted links

Every month I read tons of articles online and save the science ones for my monthly features. I happen to have found too many cool articles this month and since some of these aren’t science-article, I thought I’d throw in an assorted links posts for them. Here goes:

  •  Google gets involved in a lot of odd projects that on the face of it have little to do with their primary online search business. Well, this one may just be the oddest of them all. This article from The New York Times talks about how a Google laboratory cobbled together a machine-learning neural network from 16,000 processors and set it to the task of watching cat videos on YouTube. Result: a neural network that is really, really good at recognizing cats no matter what their size, shape or color and no matter what the cats are doing. Cue jokes about why Skynet wants to kill all humans.
  • The next article is notably mostly because of how well it lends itself to jokes. It’s America’s hottest new export and it’s man-made! Talk about gross national product! Erect a new future today! America is in good hands! Follow the link to this The Daily article to find out what it is.
  • Okay, so everyone know the Japanese are crazy about giant mecha but this post on the Anime News Network shows just how crazy that can be. Some quarters in the Japanese government are looking into the feasibility of building piloted walking combat robots and two members of the Liberal Democratic Party claim that they working to include realization of a Gundam Development Project into their manifesto.
  • This last one isn’t a joke and will likely be of interest only to Malaysians. The listing of Felda Global Ventures Holdings Bhd. (FGVH), effectively the third largest oil palm company in the world, has hit headlines due to being the second biggest IPO this year, after Facebook. This investor’s report from a Netherlands-based analyst makes for an eye-opening read since it goes far beyond FGVH’s financials into the history of the Felda project, its links with key government officials and why the settlers are so opposed to the IPO. It basically tells global investors to stay away because it’s a gigantic scam due to poor expected returns and undisclosed political risks and further argues that investing in it would be unethical as the IPO directly undermines Malaysia’s fledgling democracy.

AI Challenge 2011 Results

The 2011 AI Challenge is now over. I finished in 71st place. While that’s some way off of my 47th position in Planet Wars, considering the complexity of this year’s challenge and the fact that there was a total of 7,897 entrants this year, compared to less than 5,000 last year, I’m very glad to finish within the top 100 at all. In fact, if it weren’t for the fact that about a week before the closing date for submissions, a bunch of highly-ranked entrants publicly posted details of their combat strategy, allowing me to replicate some of it, I wouldn’t have been able to make it into the top 200 at all. As usual, this post will be about the results. I’ll write another post later about my bot in my games blog.

As with last year, once again this year’s contest was dominated by a single person. Bocsimacko who won Planet Wars last year didn’t submit an entry for Ants, but Xathis of Germany basically pulled off the same thing. For almost the entire duration of the contest, not only did Xathis keep the number one spot, he did it with the first version of his bot as well. Admittedly, it was possible only because he’d worked on his bot during the beta phase and most of his testing seems to have taken place on the TCP servers, but it’s an impressive feat nevertheless. We did have a bit of last minute tension as GreenTea of Ukraine supposedly took the number 1 spot for a couple of hours just before the finals ended, but Xathis retook the top spot just in the nick of time.

Continue reading AI Challenge 2011 Results

AI Challenge 2011 Update

Due to real-life issues, I’ve had less time to devote to the contest that I’d expected so my progress has been slow. I should have more time from here on out so hopefully I’ll be able to do better. Most people haven’t been as lazy as me however and more people have entered than I expected. As of the time of the writing, there are over 6,600 entrants. The contestant count for last year’s contest peaked at less than 5,000.

As a rough gauge of the quality of the competition, I recently climbed to the first place for Malaysians, but my overall ranking is only 800+. By contrast, the user named Jacks who self-identifies as from TM Berhad held the Malaysian top spot for over a month but in the overall rankings he peaked in the 500s and has since gradually declined to the 1,400s. This suggests a combination of very good new entrants and users who have been actively improving their bots.

Continue reading AI Challenge 2011 Update

AI Challenge 2011

Around this time last year, I participated in the Google AI Challenge, eventually finishing in 47th place out of nearly 5,000 participants. The contest this year had a bit of shaky start. There was some controversy over the name of the contest as it’s wholly organized by the Computer Science Club of the University of Waterloo. Google is providing sponsorship and has agreed to allow their name to be used but is otherwise completely uninvolved in what is otherwise a student project. Hence, this year the name is simply AI Challenge with a note that it’s sponsored by Google.

That wasn’t the only problem. Despite deciding on the nature of the game to be played fairly early on, the organizing team seemed to have a great deal of trouble coming up with the required tools, documenting everything and making sure the starter packages all work properly. It was annoying to see that while the contest had already started and is open to submissions, the website and the rules of the contest were still a work in progress. Nevertheless, everything now seems to be working correctly, apart from the fact that the server is far too slow and that there aren’t enough games being played. So I’ve submitted an entry and you can track my progress here.

Continue reading AI Challenge 2011

My Taiwan Trip

For better or worse, I’ve developed a habit of writing some notes after each of my holiday trips. I probably have less to say about this particular trip than usual and I’m been so busy at work handing over my job to the new hire that I’ve only been able to work on this in fits and starts, but I’ll do my best anyway:

  • This was a family trip. The original plan was to travel together with Shan’s parents, sort of as a filial gesture I guess. But then Shan’s mother started invited her friends along from her choir group, all elderly women. That made us a group totaling eight people. Some of the most amusing things about the trip involved interactions with these friends, but it would be rude to recount them in a public blog. Suffice to say that contrary to my fears, they were more pleasant company than expected and Shan and I were largely left to our own devices.
  • Shan was in charge of organizing the trip and had found us a driver / tour guide through a travel forum. We basically hired him to drive us around the northern part of Taiwan for four days, leaving the last two days for us to wander around Tapei on our own. This made the first part of our stay more of an extended road trip and was a bit too sedentary for my tastes, but given the company we had, it couldn’t be helped.

Continue reading My Taiwan Trip