However, the behavior is not the same as that of next_permutation.
julia> nthperm([3, 2, 1], 2)
3-element Vector{Int64}:
3
1
2
which is supposed to be [1, 2, 3]
#include<algorithm>
#include <iostream>
using namespace std;
int main(){
int a[] = {3, 2, 1};
next_permutation(a, a + 3);
for (int i = 0; i < 3; ++i){
cout << a[i];
}
return 0;
}
❯ g++ test.cpp
❯ ./a.out [127]
123