techInterview
Answers to technical interview questions - accepting donations for dogs

 
home
faq
reading
feedback
discuss
archive
fogcreek
bug tracking
pets in ny
petfinder



*new* techInterview bible


thank your brain
save a dog's life




 

Solved by Nizar Jalal

technical solution for screwy pirates

Here is solution that works for any number of pirates and any number of pirates needed to open to chest.

Let T be the total number of pirates. Let N be the number of pirates required to open the chest.

The number of locks needed would be L = (T,N-1) = (T!)/[(N-1)! * (T-N-1)!]. The number of keys each pirate would have be K = (T-1,N-1) = (T-1)!/[(N-1)! * (T-N)!].

For this specific problem, the number of locks would be 1716 and the number of keys per pirate would be 924.

I know I haven't provided an explanation of why and how this system works. We'll leave that lengthy, involved explanation to the author.

Note: the notation (x,y) is the combination notation; I can't use the conventional combination notation in plain text. (x,y) basically asks the question "how many ways can you pick y objects from a group of x objects?" (x,y) = (x!)/[y! * (x-y)!]


 



home | software development | bug tracking software | archive

[general software discussion] [dogs new york city] [Software Quality]