Suppose you have observed 10 cases above a hypothesized median and 2 cases below it. You want to test whether the difference between these two frequencies would be likely to be this large or larger if the hypothesis were correct.
The number of ways that 12 cases can be divided into groups of size 10 and 2 is 12!/(10! 2!) = 66. However, a significance level p is defined as the probability of finding an equal or larger deviation from the null hypothesis than the observed deviation. Therefore you must also compute the number of ways that 12 cases can be divided into groups of 11 and 1, or into groups of 12 and 0. The former of these is 12!/(11! 1!) = 12 while the latter is 12!/(12! 0!) = 1. Thus the total number of ways that you might have found 10 or more cases above the hypothesized median is 66+12+1 = 79. The total number of ways you could have divided 12 cases into two groups, regardless of the sizes of the groups, is 212 = 4096. Under the null hypothesis, all these various ways are equally likely. Therefore p = 79/4096 = .0193 (one-tailed).
The general rules for this calculation are:
If you are familiar with the general binomial formula you may have noticed how much simpler the procedure here is than that general formula, which includes powers of the null proportions P0 and (1 - P0). These powers can be omitted here because P0 = .5 = 1 - P0. Therefore every term in the numerator or denominator includes P0N, so these values all cancel out.