• + 0 comments

    This might be useful: https://blog.plover.com/math/choose.html

    unsigned choose(unsigned n, unsigned k) {
        unsigned r = 1;
        unsigned d;
        if (k > n) return 0;
        for (d=1; d <= k; d++) {
        r *= n--;
        r /= d;
        }
        return r;
    }
    

    I translated it to Haskell (foldr) and passed all tests.