Lets say we have $a_1<a_2<a_3<a_4<a_5\in A$ and $b_1<b_2<b3\in B$

We alse have $f:A \rightarrow B$

How many such functions $f$, so that $f(a_1)\leq f(a_2)\leq f(a_3)\leq f(a_4)\leq f(a_5)$?

Being not very combinatorial I "bruteforced" solution, wrote python/sage script, which generated functions like (tuples (A,B):

((1, 1), (2, 1), (3, 1), (4, 1), (5, 1))


((1, 1), (2, 2), (3, 2), (4, 2), (5, 3))


((1, 3), (2, 3), (3, 3), (4, 3), (5, 3))

Which yields 21 possible solutions. However for $|A|=70$ and $|B|=30$ making crossproducts like $A\times B$, and then generating all permutations of length 70 is rather silly idea.

Any tips on how to aproach this?

up vote 1 down vote accepted

This is equal to the number of non-negative integers solutions to $x_1+x_2+x_3=5$. Why? a function of this type is determined uniquely by the number of elements that are sent to $b_1,b_2$ and $b_3$.

So how many solutions does that equation have in non-negative integers. This is a standard stars and bars question, the answer is $\binom{5+2}{5}$.

In general if you want monotonic functions from $\{1,2,3\dots n\}$ to $\{1,2,3\dots k\}$ there are $\binom{n+k-1}{n}$ ways to do it.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.