def addDummyVariable(allVariables):
    """Create, add, and return a new dummy variable name.

    Specifically, the set allVariables is a set of all current
    variable names. We find a new variable name of the form d1, d2,
    d3, ... which is not in the given set. The new name is added to
    the set, and the new name is also returned.  Implemented with a
    simple linear time algorithm; of course we could do better than
    that if desired.

    Args:

        allVariables (set of str): A set of all variables in use, so
           that we can choose dummy variables that are not already in
           use.

    Returns:

        str: the new dummy variable name.

    """

    i = 1
    done = False
    while not done:
        dummyName = "d" + str(i)
        if dummyName not in allVariables:
            allVariables.add(dummyName)
            return dummyName
        i += 1