Hong-Phuc Bui
2024-05-05 5b8b6be22c49d62726f9e28fb57f6c32835900e9
python-grundlage/permutation-iterative.py
@@ -2,18 +2,20 @@
import sys
n = int(sys.argv[1])
# permutations = [[0]]
# element = 1
# n = 2
#
# next_permutations = []
# for p in permutations:
#     for position in range(0, len(p) + 1):
#         new_permutation = p.copy()
#         new_permutation.insert(position, element)
#         next_permutations.append(new_permutation)
# print(next_permutations)
"""
function permutation(set: []) -> []
    if size(set) < 2 return [set];
    result = []
    for idx, e in set:
        other_elements = set \ {e}
        other_permutations = permutation(other_elements)
        for p in other_permutations:
            result.append( [e].concat(p) )
        end
    end
    return result
end
"""
permutations = [[]]
element = n - 1