Combination of button clicks

49 Views Asked by At

The question is stated below:

Imagine a machine with two buttons: A and B. For any integer N, you have to perform N clicks on button A and N clicks on button B. It implies that the total number of clicks is 2N. At any time, the number of clicks on button B must not exceed that on button A.

(a). For any number of N, how many orders of button clicks are there?

My understandings:

I represent the orders as sets containing different orders of A and B.

Let a and b be the number of clicks on A and B respectively at a certain moment.

For example, when N=2, {A,A,B,B} is valid, while {B,B,A,A} is invalid.

In {B,B,A,A}, when B is first clicked, a is 0 and b is 1, thus it is invalid.

I have found out that:

When N=2, the number of orders = 2:

{A,A,B,B}, {A,B,A,B}

When N=3, the number of orders = 5.

{A,A,A,B,B,B}, {A,A,B,A,B,B}, {A,B,A,B,A,B}, {A,B,A,A,B,B}, {A,A,B,B,A,B}

Does anyone have an idea? Thank you.