A2 part 2 is. Really. Hard. I've been staring at it for about 2 days. I drew out a few examples; from string representation to tree representation and the other way. It's easy that way, but I can't wrap my head around the recursive aspect of finding subtrees in the parenthesis of more complex regular expressions. I first thought, "I could separate the regex at indexes of certain symbols", but then I realized there could be more than one of the same type of symbol in a regex. Then I thought, "maybe I should take out all the parenthesis", and then I realized that was an even dumber idea.
I've been trying to roll with the idea of having a helper function that checks simple regexes, like (0.1) and 2*, and then the overall function is_regex() check the larger regexes using the helper function recursively. The problem is that I don't know how to separate a complex regex without completely screwing up the order of the original regex.
The forums are usually pretty helpful to me, but they haven't been quite as useful this time around. I would have included more solid code/work in my SLOG this week if I actually had some code, but I don't have any. All I have is this rant about my struggles in CSC148.
No comments:
Post a Comment