Saturday, 9 November 2013

#6 Assignment 2

First comment that I have on assignment 2 is it is significantly shorter than assignment 1.

However, the difficulty of it is considered more or less the same as opposed to assignment 1. Only difference is the later assignment puts more emphasis on recursion.

The first challenge that came was parsing. At first I was trying to parse the string recursively. Every time we peel off the braces and parse whatever that's in the braces. However since the existence of the *s, it becomes less effective to implement using recursion. So I figured I would be better off using what I already mastered from my experience in C  --- Loop/Boolean.

Surprisingly simple to implement using the old fashion. Sometimes it's good to stick to the old ways I guess. lol.

The second part was rather straight forward. The base cases was easy to generalize. Only thing that I got stuck on was that due to nature of computer, it could get too greedy which matching things. Or sometimes it could get too reluctant. These conditions can never co-exist without artificial controls.

The only solution that came to my mind was to take into account all the possibilities, which, in nature, is very inefficient. So I had a brief convo with Danny after class and it turned out that he suggested the same way of solving the problem. The more efficient way will be covered in a second year course..

So I decided to go for the inefficient solution "any[list comprehensions]". And problem solved.

No comments:

Post a Comment