
A Math Problem from Singapore Goes Viral - klenwell
http://www.nytimes.com/2015/04/15/science/a-math-problem-from-singapore-goes-viral-when-is-cheryls-birthday.html
======
father_of_two
I'm not surprised with Singapore's kids being smart, but Albert and Bernard
really impressed me :) Here's a solver in python (just an hack, don't unleash
hate on me).

    
    
      import collections
    
      dates = '''may 15 may 16 may 19
                 jun 17 jun 18
                 jul 14 jul 16
                 aug 14 aug 15 aug 17 '''
    
      def dups(xs,pos):
          return [k for k,v in collections.Counter(x[pos] for x in xs).items() if v>1]
    
      days = dates.split()[1::2]
      months = dates.split()[0::2]
      dts = [(d,m) for d,m in zip(days, months)]
      # A doesn't know, and knows B doesn't know-- cut days occurring once
      dts = [dt for dt in dts if all(not(dt[0]==d or dt[1]==m)
               for d,m in zip(days, months) if days.count(d)==1)]
      # now B knows-- cut dup days
      dts = [dt for dt in dts if dt[0] not in dups(dts,0)]
      # A also knows-- cut months with more than 1 day
      dts = [dt for dt in dts if dt[1] not in dups(dts,1)]
      print dts

~~~
seivan
I might have missed something here, but I think your explanation for the
second "instruction" isn't exactly valid.

# now B knows-- cut dup days

You're not removing duplicate days. You're removing months that contained
"days occurring once".

Because A knows: B doesn't know. Which means A knows it's not on May and June
-the only months containing "days occurring once.

I solved it this way (in my head).

#MONTH doesn't know and knows DAY doesn't know

Remove "all days occurring once"

Remove "months that contained single occurrence days"

#DAY didn't know, but knows now.

Remove "duplicate days"

#MONTH knows now.

Remove "Months with more than 1 day"

Leaving July 16. :-)

------
kej
I like this puzzle because it's the same train of thought as this old joke:

Three logicians walk into a bar. The bartender asks "Do you each want a
drink?"

The first logician says "I don't know."

The second says "I don't know."

The third logician says "Yes!"

------
buyx
At least this article highlights how poorly worded that problem was.

Also, the article correctly points out that Olypiad questions don't
necessarily say much about the quality of an education system: if you were to
judge the Soutb African education aystem by our Maths Olympiads, you'd
probably be quite (incorrectly) impressed.

That said, many private schools here do use "Singapore Maths", so it'd be
interesting to see what sorts of problems regular students have to solve.

~~~
vonmoltke
> At least this article highlights how poorly worded that problem was.

I spent three minutes trying to parse the question before I gave up and
reverse engineered the question from the answer. I love logic problems, but
the delivery on that one was horrible.

------
btilly
As others have said, this problem is straightforward if you know how to do it.

Here is how to do it.

There is a set of possible dates. Each statement eliminates some of them. Just
get rid of all that you can get rid of at each step, and in the end there is
just one.

Here is the original set of possible dates:

May 15 — May 16 — May 19 June 17 — June 18 July 14 — July 16 August 14 —
August 15 — August 17

First Albert who knows the month says, "I don’t know when your birthday is,
but I know Bernard doesn’t know, either." That means that every day in
whatever month he heard must be in another month. From this we conclude:

\- He can't have heard May because then Bernard could have heard "19" and the
statement would be false.

\- He can't have heard June because then Bernard could have heard "18" and the
statement would be false.

\- He might have heard July.

\- He might have heard August.

We are now down to these dates:

July 14 — July 16 August 14 — August 15 — August 17

Enter the second statement. Bernard says, "I didn’t know originally, but now I
do." That means that knowing the day of the month and knowing it is one of
those two months tells him the birthday. This wouldn't happen if Bernard heard
14, but would for the other three. So we're down to:

July 16 August 15 — August 17

Enter the third statement. Albert says, "Well, now I know, too!" This would
not be true if Albert had heard August, so by elimination the answer is:

July 16.

 _yawn_

------
tr352
The puzzle is a simplified variant of the so called sum and product puzzle:
[http://www.cs.rug.nl/~grl/ds05/sumproduct.pdf](http://www.cs.rug.nl/~grl/ds05/sumproduct.pdf)

~~~
darkmighty
That's a good one, since it makes enumeration from the start prohibitive.

------
esarbe
How can Albert - from the fact that Bernard a) has knowledge of the day and b)
eliminated May and June as valid options the month value - deduce the correct
date himself? I.e. if Bernard was given the day 17, he still would known the
correct date (August 17 in this case)

But Albert can't know that. From his point of view, even if Bernard knows the
correct date, he still has three valid options to consider: July 16, August 15
and August 17.

So how can he know the correct date?

~~~
teyc
Albert was _told_ what month the birthday occurred in. We then learn from
Albert that has has enough information to work out the birthday. Which means -
he couldn't have been told August, since there were two possible solutions.

------
creamyhorror
People attempting the Singapore question fall into 2 main groups:

1\. _August 17_ : Those who (a) assume Albert made Statement 1 on the
assumption that Bernard didn't receive a unique date and thus didn't speak up,
or (b) simply eliminated May 19 & June 18 by reasoning _forward_ (as opposed
to _backward_ ) from Statement 1 alone _[1]_ (a rather common mistake)

2\. _July 16_ : Those who don't make the assumption in 1(a) or the mistake in
1(b)

July 16 is the better answer because it doesn't involve making the assumption.

Two crucial skills to get to the answer are (1) keeping perspectives separate
among Albert, Bernard & a 3rd-party observer, and (2) enumerating each
possible month (i.e. evaluating each premise) and playing out the statements
in each case. People who don't take these actions end up saying, " _There are
3 dates left at the end - how can you be sure it 's July 16?!_" They question
how Albert can possibly know the date, even though we have to assume he's
correctly concluded it. This is a perspective error; one has to put oneself in
Albert's shoes, assume a month, and reason from there to see which assumption
matches the observed statements.

As a Singaporean, I wish our question-setters had better grammar in general;
it's tripped up test-takers before. And it hurts students' language skills by
reinforcing grammatical mistakes.

 _[1] They reason forwards that "Albert says he knows Bernard doesn't know the
date" ==> "Bernard doesn't know the date" ==> "The date isn't May 19 or June
18".

Instead, they should be reasoning backwards: "Albert says he knows Bernard
doesn't know the date" ==> "Albert must have concluded this because of the
month he was told" ==> "Albert must have been told a month with a 0% chance of
Bernard knowing, i.e. a month with no unique dates"._

\--------------

By the way, this problem has floated around for a while. Here's a 2006
occurrence of it:

[http://mathforum.org/library/drmath/view/68613.html](http://mathforum.org/library/drmath/view/68613.html)

\--------------

    
    
      Date: 01/21/2006 at 00:43:08
      From: Eddie
      Subject: P -> Q <> ~Q -> ~P
    
      A teacher told the month of her birthday (let's call it M) to Peter,
      and the day of her birthday (let's call it D) to John.
      Then, the teacher showed a set of dates, and asked Peter
      and John which one was her birthday:
    
      4 Mar, 5 Mar, 8 Mar 
      4 Jun, 7 Jun 
      1 Sep, 5 Sep
      1 Dec, 2 Dec, 8 Dec 
    
      Peter said, "If I don't know the answer, John doesn't know, too."
      John said, "At first I really didn't know, but now I know."
      Peter said, "I know, too."
    
      What is the teacher's birthday?
    

\--------------

~~~
primaryobjects
Here's a program that solves this type of logic problem. It works on both
"Cheryl's Birthday" and "Teacher's Birthday".

Just replace the initialization dates with the ones from the problem.

Cheryl's Birthday
[http://www.r-fiddle.org/#/fiddle?id=8zUu1GdT&version=4](http://www.r-fiddle.org/#/fiddle?id=8zUu1GdT&version=4)

Teacher's Birthday
[http://www.r-fiddle.org/#/fiddle?id=8zUu1GdT&version=5](http://www.r-fiddle.org/#/fiddle?id=8zUu1GdT&version=5)

------
S4M
I don't like problems like this, for me it's just brute forcing: you first
eliminate the dates that would have given Albert a chance to know Cheryl's
birthday (the dates whose months have a unique day in the list), given that
you eliminate the other dates that would allow Bernard to know the birthday,
and finally you keep the date that allow Albert to know. It doesn't require
any smart thinking at all.

------
sfk
How does Bernard "know" the birthday when the set has been reduced to three
possible dates (before Albert's final statement)?

~~~
IkmoIkmo
Because he has 16.

And because it can't be May or June because then Albert would not have said
that he knows Bernard doesn't know, because if Albert had May or June then
Bernard may have had 19 or 18, and because those are unique, Bernard would
have known the birthday. Albert saying Bernard doesn't know, therefore means
Albert has July or August.

With him having 16, and 16 only being in July, and May, and Bernard knowing
it's definitely not May (see above), it's July 16.

And we can find out that he has 16, from the statement after:

If Bernard had 14, then he could not have known the correct date, because it
could have been July or August. So he could not have made statement 2.

If he had 15 or 17, then Albert would have 'August', but Albert could not know
whether the date was the 15th or 17th of August. Thus he could not have made
statement 3.

Only July 16th is compatible with all statements. And Bernard knows (as he has
16 from the start), as soon as May is out.

------
Someone
_" “Can you figure it out now?” she asked Albert.

Albert: I don’t know when your birthday is, but I know Bernard doesn’t know,
either._

That _" I don’t know when your birthday is"_ is superfluous.

I would improve things like this:

    
    
      *“Can you figure it out now?” she asked Bernard.
    
      Albert: No, he doesn't.
    
      Bernard: Now I do.
    
      Albert: Now I do, too.

------
arfliw
Think I solved it:

May 15, 16, 19 -- June 17, 18 -- July 14, 16 -- August 14, 15, 17

If A knows B doesn't know it, remove months with unique dates:

July 14, 16 -- August 14, 15, 17

If B now knows it, it cannot be 14. Remove that:

July 16-- August 15, 17

If A now knows it, has to be July 16.

------
wahsd
I wouldn't call this a math problem but rather a logic problem.

------
nickysielicki
Is this problem difficult for people with autism?

The reason I ask: [https://youtu.be/QjkTQtggLH4](https://youtu.be/QjkTQtggLH4)

------
dubya
There's a nice intro to this type of problem for kids (maybe 2nd grade and up)
called "Anno's Hat Tricks".

------
hurin
Seems like a variation on the king's wise men puzzle.

------
kyled
Core.Logic or prolog ftw

------
throwaway_97
Eh I still dont understand how you can arrive at july 16. Albert knows the
month and bernard knows the answer. How would the outside observer know for
sure?

~~~
throwaway_97
Nvm.

------
o_nate
Good interview question.

~~~
zellyn
That is a terrible interview question. First, it's likely to make candidates
more nervous, rather than set them at ease. Second, it tells you very little
if they can't solve it, or if they solve it immediately.

My rule is that you should stay away from aha! type questions that really only
tell you one bit of information.

Designing a program to solve this kind of problem might be more of an
interesting conversation…

~~~
cousin_it
Logic questions are about as far from aha! as you can get. Next you'll be
telling me that FizzBuzz is an aha! question. Sure, for some people it is,
because they don't have a clue. Others are able to solve it systematically,
and these are the candidates you're looking for.

The same holds for the logic puzzle in the OP. You can solve it step by step,
without any leaps. The main difficulty is getting over the initial
intellectual "flinch", and making yourself actually engage with the problem.
IMO that's an important skill for developers to have.

~~~
czinck
I agree, although I probably wouldn't ask this in an interview just because of
the risk of them seeing it before. At least when I was solving it it felt very
much like debugging; you have a few snapshots of the variables and you have to
reconstruct the whole logic flow.

------
baby
I love problems like that :D /spoiler: July 16th is the only possible solution

