Given the number of person(N) available and the number of locks(K) required to open a cell, give a specification of how to distribute the keys such that any K persons can open the locks, but no group of (k- 1) person can.

1<=N<=9
0<=k<=9

Ex-1 N=3 and k=1

[[0],[0],[0]]

Ex-2 For N=2 k=2

[ [0], [1]]

Ex-3 For N=3 and K=2

[ [0, 1], [0, 2], [1, 2],]

Ex-4 For N=3 and k=3

[ [0], [1], [2] ]

Ex-5 For N=5 and k=3

[[0, 1, 2, 3, 4, 5], [0, 1, 2, 6, 7, 8], [0, 3, 4, 6, 7, 9], [1, 3, 5, 6, 8, 9], [2, 4, 5, 7, 8, 9]]

Use `nCr`

Where `n = N-1`

and `r = K-1`

.

Output should be list of list.Can you elaborate what you want to say.

Yes, the list is made up of sub-lists. Sub-lists that denote the keys available to every person.

By `nCr`

I meant the number of keys each person should have.

Say, In your example 5: Given, `N=5`

and `K=3`

This is the basic question.
I want to know how to output the list of keys for each person.

Can you please recheck the last test case K is 3 but keys go till 9

neel_1
May 17, 2020, 10:53am
7
You can check the codeforces link to understand it.