Maybe I'm missing something, but the "hard" part of this problem is figuring on the trick. Once you know that, it becomes relatively easy – and you can't use a program to figure out the trick.
I thought this was a great puzzle when I first saw it. IMHO, it is more satisfying to "think through it" without paper and pencil, since it is relatively simple to resolve.<p>The Python solution proposed is really great, in that it captures both the expressive and functional spirit of the language.
This is just beautifully expressive python. I wouldn't think of using it this way: writing<p><pre><code> return (not know(possible_dates)
and all(not know(tell(Day(d)))
for d in possible_dates))
</code></pre>
feels almost zen to me; or at least like Mr. Norvig likes himself some lisp at times.
Here's my quick solution in modern SQL. This is more expensive than it needs to be, but doing it this way lets you see the truth table by commenting out the final predicate.<p>fiddle: <a href="http://sqlfiddle.com/#!15/0c419/160/0" rel="nofollow">http://sqlfiddle.com/#!15/0c419/160/0</a><p>gist: <a href="https://gist.github.com/ibejoeb/df57cb34bbe609293d6e" rel="nofollow">https://gist.github.com/ibejoeb/df57cb34bbe609293d6e</a>
The problem with this problem, the way it was originally put, was the utterly confusing English masked into a logic problem.<p>Write your specifications clearly, and then it does not become an internationally shared 'problem' to solve.<p>[I work with insanely documented specifications just like this, year after year. Not putting a problem clearly is not something to aspire to.]
For the more mathematically minded readers, here's a harder version of the problem:<p><a href="http://jdh.hamkins.org/transfinite-epistemic-logic-puzzle-challenge/" rel="nofollow">http://jdh.hamkins.org/transfinite-epistemic-logic-puzzle-ch...</a>
I'd have gone a different way since my setup and approach was a bit different (I took a more visual approach). While this solution is elegant, it's also incredibly hard to do in the real world as it requires far too much knowledge to properly assign the "correct" definitions. It's no different than having a perfect health heuristic land on your lap.<p>When I did this a while back, my approach was to construct a 5x4 matrix with blanks (5 unique dates x 4 unique months). This allowed the clues to cross off entire rows and or columns until only 1 pair stood standing. Personally, I find the construction of the solution much more interesting than the problem itself given how many people participated.
My own contribution from last week:<p><a href="https://news.ycombinator.com/item?id=9398638" rel="nofollow">https://news.ycombinator.com/item?id=9398638</a><p><a href="http://opine.me/discovering-a-new-fizzbuzz/" rel="nofollow">http://opine.me/discovering-a-new-fizzbuzz/</a>
1. HN comment about some aspect of fizzbuzz or whatever. Not how to solve fizzbuzz or whatever; rather, some insight into how people solve problems, which is the interesting part of the question.
2. Two dozen oblivious nerds tell u how to do it in 20 characters of perl
Maybe someone already mentioned this, but this problem is a simplified formulation of a famous number thoery riddle called 'The Sum and Product Riddle' which is even more baffling. Here it is <a href="http://blog.computationalcomplexity.org/2007/01/sum-and-product-riddle.html?m=1" rel="nofollow">http://blog.computationalcomplexity.org/2007/01/sum-and-prod...</a>
Friend of mine wrote a Scala solution: <a href="http://www.agileatwork.com/scala-solution-to-cheryls-birthday-problem/" rel="nofollow">http://www.agileatwork.com/scala-solution-to-cheryls-birthda...</a>
If you're puzzling over this you've done it wrong.<p>There is no inference from silence. There is no humanity in such a question, there is simply the information you're given and the application of logic to narrow down the answers. The Singaporean kids that took the exam knew this and anyone that's ever taken a maths or logic exam should know this.<p>You don't guess what might have happened from human behaviour because you don't know, you don't look for a 'trick' to give away the answer, you simply use the data in the question to narrow down the possibilities until you can arrive at an answer.<p>The moment you think "but what if this action could have taken place because if he knew he would have said" you have failed.<p>And you probably suck at debugging.
Couldn't resist. This is the solution ported to C#:<p><a href="https://github.com/kyberias/cherylsharp" rel="nofollow">https://github.com/kyberias/cherylsharp</a>
still looking for solution using RDF/OWL logical reasoning...<p>the python solution is neat, but i have a feeling that there are tools that are more native to these kind of problems than general purpose programming language.
Could one use Julia instead of Python?<p>"iPython" already supports Haskell and Julia kernels too. A iPython Javascript kernel would also make sense given its popularity and its functional inspired syntax.
Unfortunately, there are a number of rather curious, and culturally specific, assumptions one must make about the problem.<p>The real puzzles are:<p>1. "Why did Albert speak first?"<p>2. "Why did he speak in such cryptic language?"