Name: Anonymous 2010-10-11 8:55
I dont understand how to turn recursive algorythm into imperatif one.
Can /prog/ give me an exemple on this:
taking a list and generate all combinaison without double:
Can /prog/ give me an exemple on this:
taking a list and generate all combinaison without double:
def foo(cdr):
if cdr == []: return ['']
solution = ['']
for car in cdr:
tmp = list(cdr)
tmp.remove(car)
solution += [car + x for x in compose_me(tmp)]
return solution
>>> foo(['1', '2', '3'])
['', '1', '12', '123', '13', '132', '2', '21', '213', '23', '231', '3', '31', '312', '32', '321']