We were asked to make a program (in Python) that finds all possible permutations of a set of elements [1,2,...,n], where n is a user input. I started off by writing a permutaion of elements [1, 2, 3, 4, 5, 6], studied it, and wrote my algorithm. I ended up with one function that looks for the next lexicographic permutation:
Media_httpstaticflick_vctal
Also, I had to come up with a little sort fuction (I used bubble sort) to fix up the elements inside:
Media_httpstaticflick_jieju
What bothers me sometimes is what I sometimes forget why the sort method works for the permutation. Sometimes, I have to check out the code again and explain it to myself x.x Kind of pathetic, but I get kind of confused with my own code at times. Sometimes, I feel like I either type faster than I think so I get lost, or type slower than I think so I forget. Either way, I just hate it when it happens...