Jump to content
BrainDen.com - Brain Teasers
  • 0

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


Guest
 Share

Question

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.

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

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

Hint

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...