A Math Problem from Singapore Goes Viral
nytimes.com
nytimes.com
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# 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. :-)
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!"
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.
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.
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
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?
Bernard got to rule out two months based on Albert's information. Albert only had to rule out the 14th, which he did based on Bernard's being able to come to a conclusion.
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
--------------
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?
--------------Just replace the initialization dates with the ones from the problem.
Cheryl's Birthday http://www.r-fiddle.org/#/fiddle?id=8zUu1GdT&version=4
Teacher's Birthday http://www.r-fiddle.org/#/fiddle?id=8zUu1GdT&version=5
From Albert's point of view, he only knows the month and that the list is limited to the three possible dates you mentioned before. But Albert also knows that the birthday occurs in July, and the only possible remaining date of the three that would allow Bernard to figure out the birthday that is consistent with Albert's knowledge of the month is July 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.
Now if it were the 15th or the 17th Albert would not be able to reach a conclusion, but he does. So we are left with only the 16th.
The number of layers to this is more than it seems.
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.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.
The reason I ask: https://youtu.be/QjkTQtggLH4
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…
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.
First variation is with the candidates ability to solve the problem. Like you said, Microsoft and Google seem to have determined there's no correlation between that and job performance.
Second variation is with a panel of interviewers who propose the problem. Based on how the candidate responds, the panel chooses whether to 'hire' the candidate, based on their ability to reason about the problem and communicate, rather than on their ability to solve it.
I wonder if there's a correlation between the yes/no of the interviewers and the candidate's job performance.
I showed it to a few friends and a few of them had zero interest. Some tried for 30 seconds, then asked for the answer. Another wanted a hint. One said "I don't get it". One gave the answer right away and it was wrong. And some didn't get it after a decent step-by-step explanation, or even weren't interested in the explanation.
That says a lot, I think, about a certain mentality of a person towards particular types of problems, challenges and learning opportunities.
But I say mostly no, because there are hundreds of questions like these. Once you do 2-3 (and if you're in certain circles, you most likely have), the 4th or 5th become very easy, if they are even different (and not just a copy/paste) of ones you've already done.
In short, I think the question can be meaningful sometimes, give false positives a LOT of times, and probably give some false negatives, too. (e.g. nervous people who can't think outside the box in an interview boilerroom which is an a-typical work environment in my experience).
So yeah, I wouldn't personally ever use this in an interview.
For those people, it might be beneficial to stop making such assumptions -- doing so seems to reflect a tendency to jump to conclusions.
There is lots of room for tough interview questions that only a percentage of people do well, provided that your interview as a whole does not skew too much towards any one question.
Personally -- and I don't need people to agree on this point -- I'd rather setup an interviewing process where people don't ace all the questions and that is considered ok. I'd rather see how far a candidate does across, say, 10 relatively deep, hard problems, even if they only do well in a few of them. In other words, I'd rather find out where a candidate excels rather than "average out" an interview so that "on average" candidates don't think it is too hard.
To sum up what I believe to be true: heterogeneity and diversity is good, both in your interviewing questions and your team. Don't be afraid to ask tough questions -- but if you do, think hard about how you evaluate the responses.
Second, the circumstances in which you're asking candidates to solve these problems almost certainly do not reflect those in which they will be required to work should they get the job. Nervous anxiety, unfamiliarity, strong time pressure and intense outside observation are not conductive to good performance, and are (hopefully) not part of your everyday working environment, but all are present in an interview. So when you present difficult problems, you're not just selecting for people who can solve them, you're selecting for people who can solve them in conditions that will never otherwise arise.
I was able to solve the logic question in the linked article after about five minutes of head-scratching. But I am 99.9% certain that, in interview conditions, I would never have figured it out. I would have spent those five minutes of head-scratching fighting off a rising tide of panic. And the thing is, having had interviews and given interviews, I am not even particularly nervous during them, relatively speaking.