number to unique permutation mapping of a sequence containing duplicates

后端 未结 5 1132
野趣味
野趣味 2021-02-02 00:26

I am looking for an algorithm that can map a number to a unique permutation of a sequence. I have found out about Lehmer codes and the factorial number system thanks to a simila

5条回答
  •  无人及你
    2021-02-02 01:10

    A very simple algorithm to mapping a number for a permutation consists of n digits is

    number<-digit[0]*10^(n-1)+digit[1]*10^(n-2)+...+digit[n]*10^0
    

    You can find plenty of resources for algorithms to generate permutations. I guess you want to use this algorithm in bioinformatics. For example you can use itertools.permutations from Python.

提交回复
热议问题