2020/18.py
def addmul(terms):
        """
        Perform addition on all of the terms that need to be added and then do the
        multiplication.

        This isn't the cleanest solution, but it was effective.
        """
        while len(terms) > 1:
            if any(t == "+" for t in terms):
                for i in range(len(terms)):
                    if terms[i] == "+":
                        new = terms[i - 1] + terms[i + 1]
                        terms = terms[: i - 1] + [new] + terms[i + 2 :]
                        break
            else:
                for i in range(len(terms)):
                    if terms[i] == "*":
                        new = terms[i - 1] * terms[i + 1]
                        terms = terms[: i - 1] + [new] + terms[i + 2 :]
                        break
                else:
                    break
        return terms[0]

        Perform addition on all of the terms that need to be added and then do the
        multiplication.

        This isn't the cleanest solution, but it was effective.
        
Perform addition on all of the terms that need to be added and then do the
multiplication.

This isn't the cleanest solution, but it was effective.
Perform addition on all of the terms that need to be added and then do the multiplication . This isn ' t the cleanest solution but it was effective .
def addmul(terms):
        while len(terms) > 1:
            if any(t == "+" for t in terms):
                for i in range(len(terms)):
                    if terms[i] == "+":
                        new = terms[i - 1] + terms[i + 1]
                        terms = terms[: i - 1] + [new] + terms[i + 2 :]
                        break
            else:
                for i in range(len(terms)):
                    if terms[i] == "*":
                        new = terms[i - 1] * terms[i + 1]
                        terms = terms[: i - 1] + [new] + terms[i + 2 :]
                        break
                else:
                    break
        return terms[0]
def addmul ( terms ) : while len ( terms ) > 1 : if any ( t == "+" for t in terms ) : for i in range ( len ( terms ) ) : if terms [ i ] == "+" : new = terms [ i - 1 ] + terms [ i + 1 ] terms = terms [ : i - 1 ] + [ new ] + terms [ i + 2 : ] break else : for i in range ( len ( terms ) ) : if terms [ i ] == "*" : new = terms [ i - 1 ] * terms [ i + 1 ] terms = terms [ : i - 1 ] + [ new ] + terms [ i + 2 : ] break else : break return terms [ 0 ]
Perform addition on all of the terms that need to be added and then do the
multiplication.
Perform addition on all of the terms that need to be added and then do the multiplication .
"""
        Perform addition on all of the terms that need to be added and then do the
        multiplication.

        This isn't the cleanest solution, but it was effective.
        """
terms