Finished my Assignment II, didn't completely finish it. I finished the first half with some major redundancies and threw together a knowingly constrained second half. I'm still having issue with recursion and I haven't applied the effort needed to fully comprehend and take advantage of it. As such, doing part one of the assignment was pretty rough and I could barely conceive of a way to do part two.
def regex_match(r, s) -> bool:
'''Unfortunately, unfinished.
'''
if isinstance(r, RegexTreeNode):
if s == '':
s = 'e'
return str(r.symbol) == s
if isinstance(r, StarNode) and len(s) == 2:
return r.children[0].symbol == s[0]
Basically my part two takes care of a bit of the star node cases in order to scrape out a few marks, not the best but better than nothing, I was also considering a random True or False generator to see if I'd be able to trick the marker but then I thought better of it.
No comments:
Post a Comment