Yesterday we looked at counting all possible combinations of four modifier keys: Alt, Control, Shift and Window (abbreviated A,C,S,W). Today, we’re going to look at a related problem: how many different ways can we combine two of those four keys?
Of course, when your total “set size” is only four, it’s not that hard to identify them (AC, AS, AW, CS, CW, & SW) and then count them (6). But why go to all that trouble when a modified version of Pascal’s Triangle can not only do the work for you, but answer the question for any set size, and any number of choices within that set.
Let’s start with the original and slice off the sections in red:
This gives us a simplified triangle, which we can use to answer the question I posed above:
Given a set of four keys (A,C,S,W), how many ways can we combine two of them? Since the total set size is four, let’s go to the fourth row, and working from left to right, we discover that each item corresponds to the number of choices: the first item (4) tells us how many different ways one key could be combined (A,C,S or W); the second item (6) tells us how many ways two keys could be combined (AC, AS, AW, CS, CW, or SW); the third item (4) tells us how many ways three keys could be combined (ACS, ACW, ASW, or CSW); and of course the rightmost entry will always be 1, because there’s only one way to combine all of them (ACSW).
At this point, impatient readers may be wondering, “What does any of this have to do with FileMaker?” Well, it turns out that you don’t need to use Pascal’s Triangle to answer questions like these at all; you can instead use FileMaker’s Combination function, which takes this form:
Combination ( setSize ; numberOfChoices )
And you can use the Data Viewer to confirm what you saw in the fourth row of Pascal’s Triangle. Incidentally, if you’ve made it this far, you’ve been reading about enumerative combinatorics, and have my permission henceforth to refer to yourself as a combinatorialist.
2 thoughts on “Combinations and Pascal’s Triangle, part 2”
I’ve been really enjoying your posts, Kevin. Funny thing, I just became aware of the Combination function last week, while browsing the FileMaker number functions. (Not something I normally do, but I was working on a custom function to derive the second tail of Fisher exact. Fun stuff!)
Thanks Tom. I discovered the Combination function a few years ago in the FileMaker 9 Developer Reference by Bowers, Lane & Love, and wondered if I’d ever have a reason to use it (the function, not the book, which I refer to regularly, and hope to see an updated version of some day).