2015-05-19 97 views
0

我試圖做一個功能的回報所有可能的排列例如用於號碼列表:列出 = [1,2,3]類型錯誤「詮釋」

[1,2,3] ,[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]

但是我一直在相同的錯誤 類型錯誤:「INT」對象不是在這條線可調用

return permutations(result,variable,List,permutations) 

的代碼的其餘部分是

def permutationsaux(List): 
    if List==[]: 
     return [] 
else: 
    return permutations([List],0,List,countpermutations(List)) 

def permutations(result,variable,List,permutations): 
    if len(result)==permutations: 
     return result 
    elif len(result[variable])==len(List): 
     result.append([]) 
     variable=variable+1 
     return permutations(result,variable,List,permutations) 
    return permutations(result[variable]+reorderlist(List),variable+1,reorderlist(lista),permutations) 

def countpermutations(List): 
    if List==[]: 
     return 1 
    return len(List)*countpermutations(List[1:]) 

def reorderlist(List): 
    temp=List[len(List)-2] 
    List[len(List)-2]=LIst[len(List)-1] 
    List[len(List)-1]=temp 
    return List 

回答

0

你的函數「permutations」有一個名爲「permutations」的參數。猜猜哪個函數在範圍內。

+0

謝謝,我想我有點不小心 – vega2015

相關問題