A few soft questions about elementary counting methods I am reading a combinatorics textbook for my own amusement and I have a few questions. I apologize for the wall of text below.
Suppose we want to use the framework of $12$-fold way to solve the two problems below:

*

*What's the number of $5$-committees made up of $2$ men and $3$ women given that there are $7$ women and $5$ men?


*What's the number of Two Pair hands in poker?
Solutions:

*

*We have two functions $f: \{\text{men}\} \to \{\text{man$_1$, man$_2$}\}$ and $g: \{\text{women}\} \to \{\text{woman$_1$, woman$_2$, woman$_3$}\}$. Assuming the elements in the domain of $f$ are identical and the elements in the domain of $g$ are identical, by $12$-fold way we have the numbers $\binom{5}{2}$ and $\binom 73$. Then by product principle the answer is $\binom{5}{2}\binom 73.$


*I'll try to do this problem by analogy with the problem above so that men correspond to ranks and women - to suits or vice versa. Let $R$ stand for the set of $13$ ranks and $S$ be the set of $4$ suits. We have five functions: $f: R \to \{\text{rank$_{1a}$, rank$_{2a}$}\}, \ g: R - \{\text{two different ranks}\} \to \{\text{rank$_{1b}$}\},  \ h: S \to \{\text{suit$_{1a}$, man$_{2a}$}\}, j: S \to \{\text{suit$_{1b}$, man$_{2b}$}\}, k: S \to \{\text{suit$_{1c}$}\}$
Assuming the ranks and suits are identical, by $12$-fold way we get the numbers $\binom{13}{2}$, two $ \binom 42$s, $\binom{11}{1}$ and $\binom 41.$ Then our answer must be $\binom{13}{2} \binom 42^2\binom{11}{1}\binom 41$  by product rule.
What's confusing:

*

*According to $12$-fold way, the set $R$ must contain identical elements and the set $S$ must contain identical elements, but the ranks QUEEN and ACE are not the same. Similarly, DIAMONDS and HEARTS are not the same suit. So what's going on here?

*The second problem is done by analogy with the first one, but the problem (?) is that a rank and a suit are stuck on the same card which is not the case for men and women. Given how a slight change in a counting  problem can change the final answer by a factor of a gigantic number, I think some care must be taken :)

*All I did in solving the problems is to force data into the $12$-fold framework or vice versa. It's just post-hoc reasoning as I knew the answer to the problems to begin with. I don't think the very first person who counted poker hands (or anyone) thought like that. Heck, I don't think that's how any problem is solved.

*Solutions to many such counting problems seem very ad-hock especially given that human languages like English can be very ambiguous. This makes me suspect there must be better (say, numerical, algorithmic or whatever) methods for solving and checking counting problems.

My Questions:

*

*Are there any numerical or algorithmic methods for solving counting problems correctly every time? I can actually solve the problems in the textbooks I am reading, but I can't quite articulate and pin down the methods I am using in a very precise way like it's possible when proving theorems in, say, analysis. I hear whispers of generating functions, but I haven't read the chapter on that yet. Since I am studying this stuff on my own and for my own ends, I was wondering if I could simply dump these ad-hoc(?) methods of counting and concentrate on more powerful general techniques if they exist? Are generating functions that tool? If so, I could just get started reading the book "generatingfunctionology" right about now.


*If a combinatorist was asked to count the number of, say, full house hands using the $12$-fold way, how would they go about it? Is this even a correct question to ask? Also, can generating functions be used to count poker hands?
Thanks.
 A: I cannot answer your broad questions, but I can tell you how to correctly apply the 12-fold way here.
For the first problem, you are not choosing a function $f:\{men\}\to \{man_1,man_2\}$. Choosing such a function would be equivalent to assigning each of of five men one of two labels, which is not equivalent to choosing a committee. Furthermore, you have specified that the domain elements are identical; this is not what we want, because the people should be distinct. Finally, for the $12$-fold way, you must specify whether the range elements are identical, and whether the function should be injective, surjective, or no restriction. You have not specified these conditions. 
Here is the solution for the men. There are two spots in the committee, call them $s_1$ and $s_2$. Each spot in the committee must be filled by a man. Therefore, choosing a committee requires choosing a function $f$ which assigns a man to each spot, so a function $f:\{s_1,s_2\}\to\{m_1,m_2,m_3,m_4,m_5\}$. Now, we must decide three things about this function:


*

*Are the domain elements distinct? Is spot 1 different from spot 2? No. We are just choosing a committee, not a ranking of its members. 

*Are the range elements distinct? Yes, people are distinct. It matters when you switch out one man for a different one.

*Must the function be either surjective or injective? The function must be injective. This is because we must choose two different men to go to the two spots. 
Now, we have specified which version of the twelvefold way we want, and we can look up that the answer is indeed $\binom{5}2$. 

For the poker problem, the functions would be


*

*$f:\{\text{pair}_1,\text{pair}_2\}\to \{\text{Ranks}\}$ [choose the two ranks which appear as pairs. The pairs are identical, since order does not matter within the hand, but the ranks are distinct.]

*$g:\{\text{card}_1,\text{card}_2\}\to \{\text{Suits}\}$ [for the lower chosen rank, choose the two suits of the cards. The cards are identical (order does not matter), the suits are distinct.]

*$h$ is the same as $g$, but for the other suit.

*$k:\{\text{card}_1\}\to \{\text{the set of $44$ cards not appearing in the two chosen ranks}\}$, with the cards distinct. Here, we are choosing the last card which appears. This step does not need to be broken down into two steps of choosing a rank and suit.
