Wednesday, March 1, 2017

Damn you, permutations

I had such a hard time figuring out how to write a python function to generate permutations two weeks ago.

Then yesterday, I tried doing it again using a different method and I got stuck for half an hour. It finally worked when I used list.extend instead of list.append.

And then when I looked at the code I wrote two weeks ago, they were the exact same. Recursion within a for-loop. Damn. This site very helpfully explained the thinking:

def permutate(input):
if len(input)==0:
return [[]]
for index,num in enumerate(input):
to_add=[[num]+ result for result in permutate(remain)]
return output


1 comment:

  1. As we have came upon, blackjack has significantly developed. Based on the information given above, in a position to} say that it’s already not the King of desk video games. Still, it doesn’t make it much less engaging and well-liked when comparability with} different casino video games. And we believe that ultimately blackjack will see a boom again, as it nonetheless has plenty of potential level out|to indicate} sooner or later. You might need already heard about Virtual Reality and its implementation in casino 코인카지노 video games.