def assign_room(size, rooms, acceptable):
    """
    Assign a class of size people to a free room,
    and mark that room as taken.

    Arguments:
    => size - how large is this class?
    => rooms - sorted list of rooms by capacity; each item is
       a 3-tuple ( Room ID string, Room Capacity, Taken )
    => acceptable - a set of room strings that are rooms this exam can 
       be scheduled in, or None if any room is acceptable.
    Returns: String ID of assigned room, or None if no room assigned.
    """
    for room in rooms:
        if size <= room[1] and room[2] == 0:

            # If we have a specified list of rooms that 
            # this course could go in, then check if 
            # this room is one of them
            if acceptable is not None :
                if room[0] not in acceptable :
                    continue  # Can't use this room ...

            # Mark the room as taken and return the ID string
            room[2]=1
            return room[0]

    # No acceptable rooms found
    return None