def bruteForceWoTransition(words, text, measure, strl):
    if(words == []):
        return [],text,measure,strl
    else:
        wordToJoin = words[0][:]
        lastString = text[-1][:]
        lastString.append(wordToJoin)
        if(possibleString(lastString , strl)):
            text.pop(-1)
            text.append(lastString)
            newText = text[:]
            newText2 = text[:]
            newMeasure = measureOfTextEquilibrium(newText, strl)
            newWords = words[:]
            if(type(newWords) is str):
                newWords = []
            else:
                newWords.pop(0)
            
            a = bruteForceWithTransition(newWords, newText, newMeasure, strl)
            b = bruteForceWoTransition(newWords, newText2, newMeasure, strl)
            
            if(a[2] < b[2]):
                return a
            else:
                return b
        else:
            return [],[],sys.maxint,strl
def equilibre(texte, n):
    textEq = [[texte[0][:]]]
    texte.pop(0)
    result = equilibreGlouton(texte, textEq, n)
    #print result
    return result, measureOfTextEquilibrium(result, n)