The solution:
If we consider Jan 1 and Dec 31 not adjacent is given above. In the comment of the accepted answer, it is indicated that if we consider Jan 1 and Dec 31 adjacent, the number of ways to arrange the birthdays is $\binom{365-r+1}{r}-\binom{365-r-1}{r-2}$. I'm having some trouble understanding this.
Could anyone points out where I'm doing wrong?
I think this is equivalent to ask:
How many ways can we arrange 365-r $0$s and r $1$s such that the ones are not adjacent. First, for the case treating Jan 1 and Dec 31 non adjacent, I paired the $r$ ones in the following way:
$$10,10,...,10,1$$
Therefore, there are $365-2r+1$ 0s left. Then the number of ways satisfying the non-adjacency condition is $\binom{365-2r+1+r}{r}=\binom{365-r+1}{r}$, which agrees with the accepted answer.
To consider the case treating Jan 1 and Dec 31 adjacent. I do the following:
$$10,10,...,10$$
and there are then $365-2r$ 0s left. Similar argument gives the number of ways being $\binom{365-r}{r}$.
We can also think about the second case by subtracting the number of arrangements satisfying condition in the first case and Jan 1 and Dec 31 are occupied by 1.
I do the following:
$$1,01,01,...,01,0,1$$
There are $r-2$ 01 pairs and one 0 in the middle, a total of $r-1$ spots. There are still $365-2r+1$ 0s out there. Therefore, the number the ways fixing a one on Jan 1 and another one on Dec 31 while all ones in between satisfying the non-adjacency condition is $\binom{365-2r+1+r-1}{r-1}=\binom{365-r}{r-1}$. Therefore the final result is $\binom{365-r+1}{r}-\binom{365-r}{r-1}=\binom{365-r}{r}$, which agrees with my previous argument.
Could anyone points out where is wrong?