Tuesday, 25 March 2014

Week 10 - A2

So this week's slog is late. My fault? Yes, but in my defense, A2 made it difficult to work on anything else. The trouble I had with A2 was mostly that I could not think of an easy way to recursively deal with parentheses in the given regexes. It was hard to come up with a way to deal with them which also took into account the presence of the * character. In the end, I had an algorithm which basically made sure that the number of left parentheses was the same as the number of right parentheses, and which featured a decrement counter. Each time it came across a right parenthesis, it would decrement and deal with the string slice from the last left parenthesis, and check if it was a regex. Ultimately, my group did not end up using this, mostly because it tended to fail when *'s were introduced.

I feel that in this case, the recursive logic came easily, but it was difficult to properly implement into code, due to the amount of cases to consider, as well as the special characters which added complexity.

No comments:

Post a Comment