79643457

Date: 2025-05-29 07:23:53
Score: 0.5
Natty:
Report link

Sorry not to give more info. The code I can come up with so far is:

function permutations(N) {
    let c = 1;
    loop: while (true) {
        if (N > 2) permutations(N - 1);
        if (c < N) {
            swap(P, P[B[N, c]], P[N]);
            c = c + 1;
            continue loop;
        }
        break loop;
    }
}

But I never was very comfortable with the old style of pseudocode. And yes, P is the array to permute, and B is an array which Sedgewick fills with magic indices.

Reasons:
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: Hubert Kauker