help-gnu-emacs
[Top][All Lists]

## Re: puzzle with string permutations [photo]

 From: Emanuel Berg Subject: Re: puzzle with string permutations [photo] Date: Wed, 08 Jun 2022 00:04:16 +0200 User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

```Yuri Khan wrote:

> This extension of the concept of sets is called a multiset
> or a bag. For each element, we also have a multiplicity.
> Let’s write it as {o:2, g:1, d:1}.

OK, cool!

> n_perm = (n_1 + ... + n_k)! / (n_1)! ... (n_k)!

Right, that's tedious to do programming of tho (but possible
of course) because of the expanding summation and
product ...

> This problem was part of my exam in maths when I was
> applying at Novosibirsk State University, Mechanics & Maths
> Department, in 1997.

:)

> You might also notice the formula is similar to that of
> a binomial coefficient: C_{n,k} = n! / k! (n-k)!. That's
> no coincidence.

That OTOH is easy to implement, but what is n and k exactly? Can you
use that here?

(defun binom (n k)
(/ (cl-faculty n)
(* (cl-faculty k)
(cl-faculty (- n k)) )))

--
underground experts united
https://dataswamp.org/~incal

```