Number of bags of a given length with exactly d distinct elements 0 ▲ ℤ→ℤ 2 hours ago · 9 min read1816 words · Tech · hide · 0 comments We develop a formula for counting the number of bags of length \(l\) containing \(d\) distinct elements drawn from \(t\) objects. The formula involves multiplication of combinations without replacement and combinations with replacement. We present alternative forms of the formula and a generator in Python. Our motivation was computing probabilities of various types of card hands, such as how many hands of size 5 contain exactly two suites. Introduction In games, a matching mechanic may be used to restrict a player’s choice to options that match a previous play. Trick-taking games, a popular and specialized subset of matching, often restrict a player to “follow” a previous play’s cards suites or colors. In computer science, a function may assign items to specific buckets (e.g. a hash function) and we are concerned with the spread and number of collisions with a bucket. For analyzing both types of problems we likely desire to count the total number of variations possible. In our case,… No comments yet. Log in to reply on the Fediverse. Comments will appear here.