Skip to content

Instantly share code, notes, and snippets.

@eklitzke
Created February 5, 2019 00:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eklitzke/d2d2b5d6b6625b0ebbf71401380632cd to your computer and use it in GitHub Desktop.
Save eklitzke/d2d2b5d6b6625b0ebbf71401380632cd to your computer and use it in GitHub Desktop.

Problem Statement

A group of N pirates buries a treasure chest, where N is an odd number. The treasure chest is locked with multiple locks. For each lock, you may have any number of copies of the key that opens that lock. Each of the pirates receives one or more keys. The goal is to design a scheme where if any minority group (less than half) of the pirates come together, it's guaranteed that they do not have all of the keys needed to open the locks on the chest. At the same time, any majority group (more than half) of the pirates is guaranteed to have enough keys to open all of the locks. For example, if there are 11 pirates, the keys are distributed such that any group of 5 pirates cannot open the chest; but any group of 6 pirates can.

The question is: for a given value of N how many different locks do you need? And how many keys should each pirate receive?

Concrete example with N=3. Then there will be three locks: A, B, and C. Pirate 1 gets keys for locks A and B, pirate 2 gets keys for locks B and C, and pirate 3 gets keys for locks A and C.

Note: There aren't any tricks (e.g. locks locking locks, or locks locking keys). The case for larger values of N just more keys and locks, and a clever way of assigning keys to each pirate.

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