This algorithm works on a table of n choose k values for each k. e.g. for n = 4 the table looks like
a b c k = 1 d --- min(a,b) min(a,c) min(a,d) k = 2 min(b,c) min(b,d) min(c,d) --- min(a,b,c) min(a,b,d) k = 3 min(a,c,d) min(b,c,d) --- min(a,b,c,d) k = 4
Everything is written in lexicographic ordering
Now I need to get answers for $a,b,c,d$. To get my answer for say 'a', I take each combination that contains 'a' and add them as such:
M('a') = \left[ {\begin{array}{c} min(a,b) + min(a,c) + min(a,d) - (min(a,b,c) + min(a,b,d) + min(a,c,d) - (min(a,b,c,d))) \\ min(a,b,c) + min(a,b,d) + min(a,c,d) - 2 * min(a,b,c,d) \\ min(a,b,c,d) \\ \end{array} } \right]
This is for row one, taking the sum of all mins that contain 'a' where k = 1, subtracting that sum from the sum of all mins containing 'a' where k = 3 which itself it subtracted from the last k = 4 value.
For row two taking the sum of all mins containing 'a' where k = 3 subtracted from the k = 4 layer twice. And row three is left alone.
This equation actually works out to be equivalent to sorting $min(a,b), min(a,c), min(a,d)$ in descending order, and works for any n and any letter an answer is required for. e.g. if $b < c < d < a$,
M('a') = \left[ {\begin{array}{c} d \\ c \\ b \end{array} } \right]
Can someone help explain why this algorithm ends up simply sorting the values that contain 'a' in the second layer in descending order?