Hello, i am trying to learn Python and here is my problem:
In my program, i am trying to get the following result:
let say i have list of charachters E ['a','c',] and i have a N=3
As a result I should get (9 strings in total) -
aaa
aac
aca
caa
acc
cac
cca
ccc
My function bellow works, but it does not repeat the same char
it will print
ac
ca
need help, thanks
def comb(L1, n, L2=[]):
if not n: return pr(L2)
for i in range(len(L1)):
L2.append(L1.pop(i))
comb(L1, n-1, L2)
L1.insert(i, L2.pop())
permutationalgorithm that lists all possible combinations of given elements in gr
Page 1 of 1
1 Replies - 775 Views - Last Post: 23 November 2008 - 10:02 PM
Replies To: permutation
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote




|