Lab14 - CS61A of UCB(2021-Fall)


Write a function that prunes a Tree t mutatively. t and its branches always have zero or two branches. For the trees with two branches, reduce the number of branches from two to one by keeping the branch that has the smaller label value. Do nothing with trees with zero branches.

Prune the tree in a direction of your choosing (top down or bottom up). The result should be a linear tree.

Hw10 - CS61A of UCB(2021-Fall)


In this question, you will add support for grouping and piping.

Recall that grouping allows for an entire regular expression to be treated as a single unit, and piping allows for a pattern to match an expression on either side. Combined, these will let us create patterns which match multiple strings!

Define the group and pipe expressions in your grammar.

Lab12 - CS61A of UCB(2021-Fall)


Write a regular expression that parses strings written in the 61A Calculator language and returns any expressions which have two numeric operands, leaving out the parentheses around them.

写一个符合 (operand operator1 operator2) 格式的正则表达式. 这个是比较简单的, 因为这里的运算符只有 +, -, *, /. 我们用 [] 括起来就可以, 但是要注意**- 需要用 \ 转义**

Hw09 - CS61A of UCB(2021-Fall)

Write a regular expression that finds any string of letters that resemble a Roman numeral and aren’t part of another word. A Roman numeral is made up of the letters I, V, X, L, C, D, M and is at least one letter long.

For the purposes of this problem, don’t worry about whether or not a Roman numeral is valid. For example, “VIIIII” is not a Roman numeral, but it is fine if your regex matches it.

Lab11 - CS61A of UCB(2021-Fall)


Important: Your code for this part should go in buffer.py.

Your job in this part is to implement the current and pop_first methods of the Buffer class.

current should return the current token of the current line we’re on in the Buffer instance without removing it. If there are no more tokens in the current line, then current should move onto the next valid line, and return the first token of this line. If there are no more tokens left to return from the entire source (we’ve reached the end of all input lines), then current should return None (this logic is already provided for you in the except StopIteration block).