Atelier des rouesLaboratoire EN
Objets/Documentation

flux18.py

Amortir un histogramme · Programme Python reproductible.

Télécharger ↓
"""Byte-level fixed-weight binary block stream with one histogram per group."""
import json
from math import comb


def unrank(n,k,r):
    word=0
    for j in reversed(range(n)):
        first=comb(j,k) if k<=j else 0
        if r>=first:
            word|=1<<j
            r-=first
            k-=1
    return word

Lire dans son contexte

Commentaires

Les commentaires en français et en anglais sont réunis ici.

La discussion reste consultable. J’ouvrirai les participations dès que la protection antispam sera configurée.