• [^] # Re: 1er jour

    Posté par (site web personnel) . En réponse au journal Advent of code 2024. Évalué à 3.

    Voici un code de asort pour mawk que j'utilise depuis 2012.

    function alength(A, n, val) {
    n = 0
    for (val in A) n++
    return n
    }
    function asort(A, hold, i, j, n) {
    n = alength(A)
    for (i = 2; i <= n ; i++) {
    hold = A[j = i]
    while (A[j-1] > hold) {
    j--
    A[j+1] = A[j]
    }
    A[j] = hold
    }
    delete A[0]
    return n
    }