def sequence(arcs):
    """sequence: make a list of cities to visit, from set of arcs"""
    succ = {}
    for (i,j) in arcs:
        succ[i] = j
    curr = 1    # first node being visited
    sol = [curr]
    for i in range(len(arcs)-2):
        curr = succ[curr]
        sol.append(curr)
    return sol
def sequence ( arcs ) : succ = { } for ( i , j ) in arcs : succ [ i ] = j curr = 1 sol = [ curr ] for i in range ( len ( arcs ) - 2 ) : curr = succ [ curr ] sol . append ( curr ) return sol
sequence: make a list of cities to visit, from set of arcs