Jump to content
BrainDen.com - Brain Teasers
  • 0
Sign in to follow this  

Find Nth in P(M,K) or C(M,K).



1. If we have 9 colors of buttons and want to find all its permutations, we know that is P(9,9)=9!=362880. So, we can't remember all of them or find it quick. That's fine. But, how we find Nth in these 362880 permutations without record it first?

2. Same as 1, but if we want to find Nth from a permutation of M, K (M>=K and 1<= N <= P(M,K) ).

3. Same as 2. How about combination?

Logically, all permutations are independent. Therefore, Nth of the permutation can be anything or a given order.

It is no matter M equal to K or not. And, same as combination.

Mathmatically, a simple rule can be used. Let's say, there are B(lue), C(yan), G(reen), O(range), P(urple), R(ed),

V(iolet), W(hite), Y(ellow) buttons in alphabetic order.

a. Set O as N minus 1

b. Set Q as 9

c. Divide O by Q

d. Set R as the remainder plus 1.

e. Pick the Rth button.

f. Set Q to Q minus 1

g. Loop to c till Q >= 1.

For example, the 283401st permutation is:

283401 / 9 = 31489 ... 0 (Pick Blue).

31489 / 8 = 3936 ... 1 (Pick Green)

3936 / 7 = 562 ... 2 (Pick Purple)

562 / 6 = 93 ... 4 (Pick White)

93 / 5 = 18 ... 3 (Pick Violet)

18 / 4 = 4 ... 2 (Pick Red)

4 / 3 = 1 ... 1 (Pick Orange)

1 / 2 = 0 ... 1 (Pick Yellow)

0 / 1 = 0 ... 0 (Pick Cyan)

2. For Nth in P(M,K),

P(M,K) = M!/(M-K)!

So, multiply N by (M-K)!, and then get the "new" N and follow above logic.

3. Same as combination.

Share this post

Link to post
Share on other sites

2 answers to this question

  • 0
How do you determine an order? Without that, what does Nth mean?


1. The question is asking to find a "method" to generate a Nth sequence. It is not asking what the Nth sequence is.

2. Since there's no original sequence, the order is not important or impact the result.

3. It is a permutation. So, Sequence(N) needs to be unique in 362880 permutations.

And, Inside the sequence, every one color button needs to be listed 1 times.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.