Hacker News new | past | comments | ask | show | jobs | submit login
Two logic puzzles (nickyee.com)
29 points by RiderOfGiraffes on Dec 24, 2009 | hide | past | favorite | 36 comments



1. A puts amulet in the safe, puts lock on it, sends to B. B puts lock on it, sends back to A. A unlocks his lock and sends it back to B. B unlocks and receives the amulet.

2. Take 20 coins aside, and flip them - this is one group. Take the 80 remaining coins - this is the second group. If there were X (0 \leq X \leq 20) queens in the first group, then there were 20-X queens in the second group. Since we flip the 20 coins in the first group, there are now 20-X queens in the first group as well.


I guess that's the right answer, but it's not really satisfying. If the servants can walk off with the safe to crack it at their leisure, how is it secure?


The moral here is that the more colorful you try to make your logic puzzle, the more implausible the correct solution will be.


I used to think that I was pretty good at puzzles like this.

That is, until I met a girl that just simply aced them, one after the other, and in record time at that.

It's the first time that I ran into very solid proof that brains definitely are not created equal, I've never met anybody in my life that even came close to that level of problem solving ability. It's akin to the difference between a chess grand-master and someone that just plays a half decent game of chess, some people operate on a different plane altogether, they are so good at attacking a problem in parallel from all sides at once that what seems confounding to one person is a walk in the park for them.

If you solve the second puzzle in 5 seconds or so because you simply 'see' the solution then you fall in to that group, consider yourself a very lucky person, I wonder how rare such talent really is.


I was thinking "eh, just like my brother used to", so I told him the problems and he solved both in about 5 mins (although the first one the same way I did, it seems trivial if you can ybpx gur fnzr fnsr jvgu obgu ybpxf ng gur fnzr gvzr but also seems slightly wrong)


Did you know there's a puzzle called "The Hardest Logic Puzzle Ever"?

http://en.wikipedia.org/wiki/The_Hardest_Logic_Puzzle_Ever

I extended it to the general case!

http://www.srcf.ucam.org/~te233/maths/puzzles/evenharder.htm...


I agree that they are difficult, but for me, they fall into the category of:

  "I can probably solve these by long and convoluted
   means, but I suspect the solution is neither clean
   nor elegant and, to be frank, I can no longer care."
The beauty of the 100 coins problem is that the solution, once seen, is clean, simple and elegant, and it is possible to reason to it - it doesn't require complete inspiration from nowhere.

That's why I liked it so much. YMMV.


Actually the solution to the 3 god version is clean and elegant, and long and convoluted reasoning doesn't shed any light on it.


I like the solution to the variant of the Knights and Knaves problem in Every Man For Himself And God Against All by Werner Herzog.

To determine the liar, Kaspar Hauser asks both people -- the liar and the truth teller -- if they are a tree frog.


WARNING: SPOILERS FOLLOW

If you want to read on, do so. If people up-mod this comment then it will stay at the top.

In case you don't want me to get the karma, up-mod it anyway, and down-mod the other comment to balance it out. Here's the link:

http://news.ycombinator.com/item?id=1013881

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.


The description says you have five minutes to complete the task. So just move any ten coins to a new pile. Continue moving one coin at a time while asking if you have completed the task. You will have to move at most eighty coins after the initial ten. Since you have five minutes to do this, you'll have about 3-4 seconds per coin for the captor to reply if you've solved it yet.

The solution someone posted to flip each coin after picking out twenty is faster but flawed; it would be too easy for a nervous and blinded person to flip the same coin twice. The best solution would be to flip each coin as it's drawn from the initial set of one hundred.


My solution for #1 - not sure if it is correct. I didn't expect that two locks could fit in the clasp.

Person #2 sends the safe back to Person #1. It has nothing in it.

Person #1 locks his own safe to the safe of person #2, making sure the clasp of his safe is over the latch pin of the second safe. Again he sends it back with nothing in it.

Person #2 repeats this; now you have two safes locked together (with the latch pin being on top of opposite clasps). He sends the safe back to person #1.

Person #1 unlocks his lock, puts the amulet inside, and locks it again. He sends it back.

Person #2 unlocks the other side, and now has both safes, plus the amulet.


I got #2, and I have a solution for #1, but I don't think it's right. Here's my non-right solution to #1:

G places the amulet in his own safe, locks it with the padlock, and keeps the key. G sends the safe to K by way of a servant. K takes the safe with him and uses whatever tools to open it at his convenience once he is safe away.

I think this is wrong, because it's not very satisfying at all. I think it could be right, because (1) it could work in real life and (2) it meets the solution criteria of the puzzle, namely, transferring the amulet from G to K.

I would be happy to know of a more elegant solution.


Sorry, but I don't think that this solution is correct. This is a classic "Alice and Bob" security/encryption problem. G should place the amulet in his own safe, lock it with the padlock and send it to K. K then adds her own padlock onto the safe and locks it (now there are 2 padlocks locking the safe). K sends the safe back to G and G unlocks his padlock. He sends the safe back to K whereupon she may unlock the only remaining padlock with her own key. See http://en.wikipedia.org/wiki/Public-key_cryptography#A_posta... for more.


That was the first solution I had for #1. I'm currently at the following, but I think there has to be a better one because it's not clear that it would be possible.

G places the amulet in his safe, attaches his padlock and locks it with his key, then sends it to K, keeping his key. K receives G's safe, attaches his own padlock in addition to G's (there is a "large clasp", no mention of how large or how many padlocks it could support) and sends it back to G without sending his key. G removes his own padlock, and sends the chest back. K removes his padlock and has the amulet.


I think your current solution is clearly the right one: It gives me the 'duh' moment.

Edit: But in real life the first solution might work better. Hard to imagine the henchmen who would be sure to spot you if you left your room even for a moment but would take no notice of servants shuffling back and forth three times with a [double-]padlocked safe.


reason it is unsatisfactiry (I had the same) is that one of the safe is not used, imo


It's a charasteristic of the real world that there are things not used in the solutions of the various problems that need to be solved.

It is one of the most brain-dead characteristics of school and university exams that one is not allowed to have extras - it's somehow "not fair."

I think not using some of the resources provided is perfectly reasonable.


apple and oranges, if the beauty of the problem is in a clean elegant solution that does not require all of the pieces, it is not a well posed riddle, or solution.

That's why the solution to the wolf-sheep-cabbage problem is not "just add more floating stuff so you can bring all at once, idiot".

The comparison to school and exams, appears unrelated to me: there are situations where external aid kills the point (e.g. calculator for arithemitic in firs grade).


Then I must not have explained myself clearly enough. I'm not talking about extra equipment, I'm talking about information that's not needed for the solution to the problem.

Recently (for some definition of "recent") I was setting an exam question. In it I gave various lengths, heights, and so on, and I was told that it was too hard because I gave details that weren't required. On the other hand, if one is given only the information required, there is already an artificial clue - all the information given must be used. That's unrealistic.

I've interviewed people for jobs who performed fantastically well on exam style questions, but when given free-form problems simply didn't know where to start.

For me, whether a solution is clean and elegant is independent of whether you've used all the information given. It's the solution itself that's elegant. It's not only plausible but likely that we have different concepts of elegance - I'm a mathematician. When solving math problems, real math problems such as required to get a PhD or publish a paper, there's no way you're given just the information required and no more.

Along those lines I've been moved to submit another puzzle - you can find it here:

http://news.ycombinator.com/item?id=1014092


What's to stop the servant from making off with the safe if they can carry it in the first place ?


There is provably no solution if the servants simply make off with everything given to them. I think we have to assume that they don't steal secured (i.e. locked with a lock) safes.


Then I think the puzzle is somewhat flawed.

If the premise is that it is a 'logic' puzzle and in the end it depends on the cooperation of the servants then in 'real life' there would be no solution.

After all, the 'real life' problem is what sketches the background for this, otherwise why bother with that?

My personal favorite for little (smart) kids:

A farmer has to cross the river, he has with him:

  - a wolf

  - a sheep

  - a cabbage
The boat that hast to take him across the river will only hold one item besides the farmer, what is the sequence of moves that will get the farmer and his possessions to the other side without the sheep eating the cabbage or the wolf eating the sheep ?


Respectfully (and we've communicated - so you know I mean that literally and am not being sarcastic) we'll have to disagree. I think it's reasonable that the servants don't make off with things genuinely of no value, so locked padlocks without keys, and locked safes, are "safe" and not stolen. I think it's reasonable that they make off with anything remotely of value, such as a padlock and key, or (of course) the amulet, but not the amulet when it's locked in the safe.

I agree that the farmer puzzle is nice for kids, but it yields to "try it, oh, that works, ok, I'm done." There's no real insight from it.


I figured out the answer, but only by assuming things (that they won't take a locked safe). But if I can assume that, can't I also assume they won't take a key by itself, since it has no value?

Would they take an empty safe? What about a locked padlocked, without a key, not locked onto anything?

I think it's better to make these things explicit in the puzzle.


I'm puzzled over the difficulty people are having with number 1. Surely it's pretty obvious given public-key cryptography ...


I thought it was obvious because I have never come across a person who hasn't dealt with the logic problem where the farmer has to get a few of his animals across a river, one at a time, and must do so in a sequence where no animals will kill each other. There was some vicious animal included.

I immediately recognized that problem #1 is very very same problem, but worded differently.

But it sounds like you and I have different solutions...?

Edit: Oh okay, I had to look up public-key cryptography. I thought you meant slip each other secret messages or something.


It's also exactly the technique Simon Singh uses in one of his books to explain public-key cryptography...


Spoiler: The solution is very easy for problem # two if you're allowed to flip the coins.

I haven't worked it out since I've been up all night and had to squint just to read the problem, so I may have read it wrong. I didn't read the first question.

Have fun.

----

Edit: Just great, seeing this right when I'm about go to sleep after a long night. And it appears what I had in mind doesn't work.


No, no. You were on the right track. Think about it with a smaller number of coins, say 4 coins and you know only 1 is Queen side up.

On the first one: I get the feeling this isn't what the puzzle was looking for, but I'd just lock the amulet up in the safe, send it to the other spy, and let them spirit it out of the country. What, does my country not have bolt cutters?

Edit: Spoiler hint for the first one: Start by sending over an empty safe with the padlock locked on only one handle of the safe.


I know that many, perhaps most, of you hate logic puzzles, especially as selection or hiring criteria. And that's fine.

However, the second puzzle on this page is, I think, particularly nice. Feel free to ignore it.


I disagree with the premise: there are a lot of elegant logic puzzles (consider: to mock a mockingbird), it's just that a lot of puzzles dod not fall in this category :)


Downmod this if you don't want me to get the karma from up-voting the spoiler warning.


What kind of hotel room has moveable safes? The ones in the rooms I've been in are fastened down. What kind of thief would steal anything except for a portable safe? Couldn't you kidnap one of the thieves, steal the clothes, and disguise yourself? How would exchanging safes in the middle of the night not be noticed? Couldn't the henchmen just open up every room looking for them?

Don't safes have built-in locks? My dictionary says a safe is "a strong fireproof cabinet with a complex lock, used for the storage of valuables." That definition does exclude some categories of safe, but "strongbox" or "lockbox" might be a better word.

Having now seen the answer here, I didn't even think that the clasp (shouldn't that be "hasp"?) might be big enough to admit two locks. That seems like a poorly designed safe, since that means the door probably opens enough to admit a crowbar.

Yes, I knew when I started that the answer was "public key cryptography." I'm just complaining that the puzzle wasn't well stated. Besides, if we're going along those lines, what if the henchmen start sending safes into every room to see if it comes back with an extra lock on it? That gives them idea of where the bad guys/spies might be, and prevents the spies from being able to make the exchange.


Presumably the choice of the word "safe" (and perhaps "clasp") was to make the solution hard to search for. Traditionally, the word "chest" is used.

http://www.google.com/webhp?hl=en#hl=en&q=chest+lock+key...


Ah! I am enlightened. Thanks!




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: