Skip to content

Instantly share code, notes, and snippets.

@randuhmm
Created May 21, 2019 01:18
Show Gist options
  • Save randuhmm/c48a92a68880cab577155a715106bc69 to your computer and use it in GitHub Desktop.
Save randuhmm/c48a92a68880cab577155a715106bc69 to your computer and use it in GitHub Desktop.
Brain Teaser for Hockey Fans - 01

Question:

In a best-of-seven series, how many different ways can two teams alternate wins/losses to reach a seventh game?

Answer:

Twenty ways.

Below are the twenty ways written out manually. We are only considering the perspective for one team because it's just a matter of your frame-of-reference.

WWWLLL
WWLWLL
WWLLWL
WWLLLW
WLWWLL
WLWLWL
WLWLLW
WLLWWL
WLLWLW
WLLLWW
LLLWWW
LLWLWW
LLWWLW
LLWWWL
LWLLWW
LWLWLW
LWLWWL
LWWLLW
LWWLWL
LWWWLL

The logic and math behind this is a little more subtle.

Even though we are talking about a seven-game series, we are really only interested in the first six games where each team has won exactly three games. To figure out all the different ways this can happen, we can use combination mathematics which is used to determine how many different ways you can select items from a collection where the order that they are "selected" is unimportant. The reason order doesn't matter is because selecting games 1, 2 and 3 is equivalent to selecting games 3, 2 and 1. The item itself represents the game number, and the order it is "selected" is irrelevant. Think of it like drawing 3 numbers out of a hat that contains 1 through 6, if you draw out 1, 2 and 3 you end up with the same set as if you drew 3, 2 and 1.

We basically have a collection of six games and we need to find out all the different ways to choose three.

We can turn to combinations (https://en.wikipedia.org/wiki/Combination) mathematics to solve this.

The formula for a combination is:

combination formula

Where n represents the total items and r represents the number of items cosen (nCr is also referred to as n Choose r).

If we let:

n = 6 and r = 3

We arrive at our solution:

solution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment