11

I have an admission to make: I very rarely put my DVDs back in the case they came from. Whenever I watch a new DVD I just put whatever DVD is the player in the new case. I put the cases back on the shelf wherever they'll fit without worrying about any sort of order. My collection is very disorganised! Now I want to watch my favourite movie The Life of Pi but I have no idea which case I put it back in! The right case has The Fifth Element in it. I've tried opening a few cases at random but I have so many it's going to take me forever! I know I've watched it fairly recently, I just can't remember which case I put it back into or all of the DVDs I have recently watched. The DVD currently in the player is Four Weddings and a Funeral and its case is empty (it happened to be in the right case before I watched it).

Sometimes, when people come over, I tidy the house, which means I take the DVD out of the player, stick it into the empty case and put it back on the shelf. And sometimes I put the DVD into the already empty case regardless of whether it's the right one or not (when I select a new DVD I briefly have two empty cases. The old DVD might end up in either of them, but usually the new case). I don't really have a system which is why they're so jumbled.

I'm not going to buy another copy, I don't belong to a video library, none of my friends have it and my internet is too slow to download it. I only have one DVD player. I know the DVD is in the wrong case somewhere on my shelf. I must find it in my own collection as quickly as possible! How can I do it?

This is a logic puzzle. It is not a trick question. It does not rely on an obscure interpretation of certain words or lateral thinking to get around any conditions. I believe I have given sufficient clues to be able to answer the question but I will be happy to clarify any points. I don't believe I need to provide any extra clues.

CJ Dennis
  • 386
  • 1
  • 10
  • 1
    Are you sure that this has an unique solution? – Victor Stafusa - BozoNaCadeia Dec 07 '14 at 09:50
  • @Victor No, I'm not sure. But I have a solution I believe to be optimal. If someone comes up with a better solution I'd be interested to see it! Also, I've rolled back your edit. I meant exactly what I said. This is not a trick question (it's not designed to trick people). Whether it's tricky or not depends on each person solving it. And commas are usually not needed before a conjunction. – CJ Dennis Dec 07 '14 at 09:56
  • 1
    Ok then, sorry for that. – Victor Stafusa - BozoNaCadeia Dec 07 '14 at 09:59
  • I had an idea, but I think it would only work if you watched each movie once :P damnit – Sp3000 Dec 07 '14 at 10:01
  • @Victor No worries. The comma thing is just my personal style. Feel free to keep using them yourself! As far as I know both are acceptable. – CJ Dennis Dec 07 '14 at 10:03
  • CJ, I feel like I'm missing something here. Is there an equal likelihood of the CD being in any case? (except for the 4W&F case which we know is empty and the Life of Pi case which we know contains 5El). – A E Dec 07 '14 at 10:10
  • @AE Yes. Due to my less than perfect memory the DVD could be in any case. What I do know is that it's not in the Four Weddings and a Funeral case (because it's empty), nor is it in its own case or any of the randomly selected cases I've check so far (they've all got other DVDs in them, some right, some wrong). – CJ Dennis Dec 07 '14 at 10:14
  • 1
    OK.... so then why isn't the answer just to check each case except the ones you've already checked (checking them in any order, so long as you only check each case once) until you find it? – A E Dec 07 '14 at 10:20
  • On average I will have to check half of my very large collection to find it (I have hundreds of DVDs: movies, TV shows, music bands, etc.) I really want to watch it as soon as possible! There must be a way to find it faster than looking through half the collection. – CJ Dennis Dec 07 '14 at 10:24
  • How do you choose which movie to watch? Do you randomly pick a case on the shelf? What if it's empty? – Sp3000 Dec 07 '14 at 11:02
  • @Sp3000 I watch whatever I feel like at the time. Sometimes the wrong DVD is in the case and I either have to search for it or watch something else (or watch the wrong DVD if I feel like it!) There is always a DVD in the case if it's on the shelf. The only empty case is on top of the DVD player. This time, though I have to watch The Life of Pi! – CJ Dennis Dec 07 '14 at 11:08
  • 1
    @CJDennis Just to check I haven't gotten this wrong, say you watched the first movie you ever watched. Then DVD 1 is in the player and case 1 is empty. Then when you watch the second movie, DVD 1 goes into case 2, DVD 2 goes into the player and case 1 is still empty. As far as I can tell, won't case 1 always remain empty? – Sp3000 Dec 07 '14 at 11:14
  • @Sp3000 Good point! I do sometimes tidy the house when people come over, so I just take the DVD out of the player, stick it into the empty case and put it back on the shelf. And sometimes I put the DVD into the already empty case regardless of whether it's the right one or not (when I select a new DVD I briefly have two empty cases. The old DVD might end up in either of them, but usually the new case). I don't really have a system which is why they're so jumbled. However, I believe this should not affect the solution. – CJ Dennis Dec 07 '14 at 11:25
  • 1
    It affects what I was going to post. If you didn't specify that I had a post prepared saying Four Weddings and a Funeral was the first thing you ever watched (and more) ;) – Sp3000 Dec 07 '14 at 11:27
  • @CJDennis On average you have to check 1/2 of your very large collection? Yes, but you can amortize that to O(1) if you simply run a single pass across all your discs to put them in the right cases. Then after that, simply put each disc back in the case it belongs in, and you'll never have to look in more than one case ever again! – Michael Dec 08 '14 at 00:21
  • @Sp3000 I mentioned that Four Weddings and a Funeral was already in the right case, implying that I'd taken it off the shelf last and not that I'd gone through my entire collection once. Admittedly, that could have been a bit clearer. – CJ Dennis Dec 08 '14 at 01:16
  • Wouldn't one call this a duplicate of the 100 prisoner names in boxes problem? – Alexander Dec 08 '14 at 10:42
  • @Alexander That seems like a very different problem to me. The answer is not obvious to me and I haven't put any serious thought into trying to solve it. – CJ Dennis Dec 08 '14 at 10:55
  • 1
    internet is too slow to download it Ridiculous. You'll have it downloaded before the 10 minutes of unskippable features are finished playing from the DVD. – FreeAsInBeer Dec 08 '14 at 13:57
  • @FreeAsInBeer my internet, not the internet, which is probably true for me in real life. I think it would take longer than 2 hours for me to download a high-res movie. Of course, if I selected a low-res, highly pixelated version I could have a very disappointing viewing of my favourite movie! – CJ Dennis Dec 09 '14 at 03:06
  • @CJDennis Was joke. Many sarcasm. Such funny. – FreeAsInBeer Dec 09 '14 at 13:59

4 Answers4

15

All of your DVDs are in n rings, where n >= 2 (Four Weddings And a Funeral is in a ring of length 1). So if you open a DVD at random, it may or may not be in the ring that contains The Life Of Pi.
However, we do know one movie that is in the same ring as The Life Of Pi. It is The 5th Element. So if you start with The 5th Element's case, you are guaranteed to be in the ring that contains The Life Of Pi.

You should really consider getting yourself a NAS and a copy of Plex (or other similar software), so that you can stream your movies locally and avoid this problem in the future.

Joel Rondeau
  • 7,540
  • 1
  • 30
  • 44
  • 5
    But then I'd have to put the file back in the right directory after I'd watched it... – CJ Dennis Dec 08 '14 at 01:27
  • 1
    Why is this faster than opening cases is any other order (until you find The Life of Pi)? – Julian Rosen Dec 08 '14 at 04:36
  • @JulianRosen I have created a chat room to discuss this: http://chat.stackexchange.com/rooms/info/19275/help-me-find-my-favourite-dvd – CJ Dennis Dec 08 '14 at 06:42
  • It's a clever solution. Worst case the amount of cases to be opened is still close to n (or even N) but the odds of that worst case are severely limited. – Weckar E. Nov 16 '16 at 10:01
2

Take the DVD cases to be indices of the array elements in the following explanation. Let the DVDs themselves to be the values in the array elements.

Let us establish the means by which this problem may be solved:

Take the array $C = [1,\cdots,n]$. It contains each integer from $1$ to $n$ and is of size $n$. Consider any permutation of the elements of $C$. There are $n!$ ways $C$ can be shuffled. We have a searching algorithm which is to find $1$.

Start with checking in $C[1]$.
If $C[1] = 1$ then we have found $1$ in $1$ check.
If $C[1] = x$ where $x\not=1$ then we check $C[x]$. If $C[x] = 1$ then we have found $1$ in $2$ checks.
If $C[x] = y$ where $y\not=1$ then we check $C[y]$. If $C[y] = 1$ then we have found $1$ in $3$ checks.
If $C[y] = z$ where $z\not=1$ then we check $C[z]$.
This process can be continued and it forms a chain. Clearly, $x \not= y \not= z$ - so long as $C[i] \not= 1$, no number previously encountered will be repeated ($Lemma1$). The claim is that this chain will include $1$ because we started with $C[1]$.

The proof is by contradiction. Assume that $1$ is somewhere outside the chain.

Recall that $|C|=n$. Start from $C[1]$. Clearly, any chain including every element of $C$ will include $1$. We must be looking for a chain of size less than $n$. Such a chain must moreover be a loop - otherwise it must continue and consume all elements of $C$, and $n$ is finite. Therefore, we know that we are looking for a loop starting from $C[1]$ which does not contain $1$. A loop is a chain of length $z$ where the last element visited contains the value contained in the first element visited. By $Lemma1$ given a loop of length $z$, the loop must involve $z$ elements and only the values being the indices of the elements. So, a loop, in order to arrive again at $C[1]$ must have included $1$. Contradiction.

As to the concerns of efficiency, in particular, to defeating randomly checking:

If we add one constraint (which may exist in many forms), that the loop in which the target, $1$, can be found, is smaller than $n$, then we can guarantee better than random chance performance.

Randomly checking has a worst-case runtime of $n$ checks.

We can constrain the loop housing $1$, $L$, which will be of size $z$, to have $z < n$ by simple asserting that there is a guarantee that some of the elements have not been moved - or that there exists a loop outside $L$. NB: These constraints/guarantees are equivalent since is an element has not been moved then it is a loop of size $1$.

Checking $L$ as described above has a worst-case runtime of $z$ checks.

Since $z < n$ this strategy is "better".

d'alar'cop
  • 12,892
  • 4
  • 49
  • 90
  • In this problem, we only know about one disc that's in another loop, so $z=n-1$. It's not clear that this strategy is faster than checking all of the cases except Four Weddings and a Funeral (and if the other discs are distributed randomly among the cases, this won't be any faster) – Julian Rosen Dec 08 '14 at 16:10
  • @JulianRosen Indeed, I did not intend to contest that what you say is not true. In fact, what I say out right implies this. Notice that the accepted answer is the same as this strategy. Now, the point is that it's better than random because z < n (note: $z=n-1 \rightarrow z<n$), but yes, if you know what the loop is (and in this case you DO, by excluding Four Wedding and a Funeral) then you may as well check them in any order you like – d'alar'cop Dec 08 '14 at 16:15
0

It's a matter of Derangements (arrangements that map each dvd to a case ,other than its own) It is an "NP-complete" problem (that means HARD) to determine whether a given permutation group (described by a given set of permutations that generate it n! for n cases and n DVD's) contains any derangements http://en.wikipedia.org/wiki/Derangement

George R.
  • 487
  • 3
  • 5
  • 2
    This is not a derangement because I mentioned that Four Weddings and a Funeral was in the right case before I watched it. – CJ Dennis Dec 07 '14 at 09:58
-4

I know this is a logical puzzle so the following answer is not what you're looking for, but I think it is a valid answer if lateral thinking is allowed.

Put the following announcement into a (free) newspaper / online-blog etc.:
"Free video rental for the curious! Feel bored? Are your ready to try something unexpected ? I'm giving out (lending!) DVDs for free - for a limited time only. And this is how it works: You come by my place (see Google-map below) and I'll hand you out a random DVD case with a random DVD inside! No guarantees whatsoever about the content - but all my films are best quality mainstream films (no porn). You've a 24hrs period to watch and return the DVD, and the only condition: You have to tell the title of the film you've watched.

Now simply wait and the problem will solve itself. Is it the fastest solution? I don't know yet as no other answer has been posted. It will depend on the size of you library though, because it scales. The bigger your library, the better my solution in comparison!

Of course there would be a faster alternative:

Invite all your friends (or trustworthy people you know) for a "picke & watch" DVD evening. Everybody may come and take (borrow!) as many DVD as he likes except the one you want to watch for yourself. Condition: Open the DVD case at once and check.

BmyGuest
  • 18,141
  • 1
  • 69
  • 147
  • 2
    I don't give downvotes but I would explain them like so: 1. I specifically said no lateral thinking, logic only. 2. The amount of time required to organise your solutions would not be optimal! – CJ Dennis Dec 08 '14 at 01:26
  • @CJDennis fair enough. Point 1 is clear and having read the accepted answer I agree to 2 as well. – BmyGuest Dec 08 '14 at 06:03