Wednesday, 13 November 2013

Midterm 2

I thought I did well, but I just realized that I made an incredibly absentminded mistake.  Instead of using n.item/n.right/n.left, I accidentally used self.______ instead. I'm actually feeling pretty disappointed in myself because I'm almost 100% certain that if I were to replace every instance of self.______ with the appropriate n._____, then my code would work just fine. I don't know, it's just a very brutal mistake to me, because I don't think I'm normally that incompetent. Furthermore, I didn't do particularly well on the last midterm, either, so this is all kinds of disheartening. Mistakes happen, and I'll try to let it go. Maybe I'll ask Danny how much I could possibly lose for it; knowing will probably alleviate some of my anxiety.

Sunday, 3 November 2013

On Assignment 2: Part 2

So what I've been doing isn't working. I have no idea how to handle this; what an incredibly frustrating situation. I know exactly where the problem is, but I have no workaround. No, that's false; I have a way to deal with the problem, but it's ugly and long-winded. Also, I feel like I'm a bad partner for being unable to get this done. These are the four test cases I'm trying to make our code work with:

    >>> string_to_tree('(0***.1)')
    DotNode(StarNode(StarNode(StarNode(RegexTreeNode(0, [])))), RegexTreeNode(1, []))
    >>> string_to_tree('(0|(0.1***))')
    BarNode(RegexTreeNode(0, []), DotNode(RegexTreeNode(0, []), StarNode(StarNode(StarNode(RegexTreeNode(1, []))))))
    >>> string_to_tree('(0***.1***)')
    DotNode(StarNode(StarNode(StarNode(RegexTreeNode(0, [])))), StarNode(StarNode(StarNode(RegexTreeNode(1, [])))))
    >>> string_to_tree('(0|(0.1)***)')
    BarNode(RegexTreeNode(0, []), StarNode(StarNode(StarNode(DotNode(RegexTreeNode(0, []), RegexTreeNode(1, []))))))

Unfortunately for me, it just won't happen. The first case is the simplest that we're trying to make work. Then the nested scenario. Then multiple instances of nested StarNodes, then one in which the StarNode applies to another BinaryNode. It works if the string were, say, '(0|(((0.1)*)*)*)', but trying to construct a new string has been an exercise in, if not futility, than absolute madness. I'm not too sure what else to do, though. Creating a new string with brackets around the designated areas is difficult, but trying to fix the current mutually recursive helper functions is also ridiculously difficult, too. What a pain.

On Assignment 2: Part 1

Or however many parts I'll be going through.

There's something wrong with how we're parsing the strings. It fails only in this one, very specific scenario. And the harshest part about it failing is that the way we've coded the parser means that a) it works perfectly fine for anything else of arbitrary complexity, and b) it's mutually recursive. My partner handled the main bulk of it, and I'm trying to edit it now, but it's really tough to not screw up all the previously working test cases. At this point, I'm working around it in the most convoluted way, which irritates me because, well, bad code is bad code.