找到第n個排列而不計算其他排列給定表示置換原子的N個元素的數組,是否有類似的算法:function getNthPermutation( $atoms, $permutation_index, $size )其中$atoms是元素數組,$permutation_index是置換的索引,是置換$size的大小。例如:$atoms = array( 'A', 'B', 'C' );// getting third permutation of 2 elements$perm = getNthPermutation( $atoms, 3, 2 );echo implode( ', ', $perm )."\n";會打印:B, A沒有計算每個排列直到$ permutation_index?我聽說過關于事實排列的一些事情,但我發現的每一個實現都會給出一個具有相同V大小的排列,這不是我的情況。
找到第n個排列而不計算其他排列
慕碼人2483693
2019-08-12 18:43:50