Suppose we want to encode a large integer \$x\$ as a list of words in such a way that the decoder can recover \$x\$ regardless of the order in which the words are received. Using lists of length \$k\$ and a dictionary of \$n\$ words, there are \$\binom{n+k-1}k\$ different multisets possible (why?), so we should be able to represent values of \$x\$ from \$1\$ through \$\binom{n+k-1}k\$.
This is a code golf challenge to implement such an encoder and decoder (as separate programs or functions); your golf score is the total code length. Any sensible/conventional input & output formats are allowed.
Encode: Given positive integers \$n,k,x\$ with \$x\le\binom{n+k-1}k\$, encode \$x\$ as a list of \$k\$ integers between \$1\$ and \$n\$ (inclusive).
Decode: Given \$n\$ and a list of \$k\$ integers between \$1\$ and \$n\$, output the decoded message \$x\$.
Correctness requirement: If encode(n,k,x)
outputs \$L\$ and \$\operatorname{sort}(L)=\operatorname{sort}(M)\$, then decode(n,M)
outputs \$x\$.
Runtime requirement: Both operations must run in polynomial time with respect to the length of \$x\$ in bits. This is meant to rule out impractical brute-force solutions that just enumerate all the multisets.
codegolf
tag. Or rather I would suggest it if there weren't already an answer. \$\endgroup\$