17
$\begingroup$

This is inspired by the following recent question: Living next door to Alice

Having failed to figure out where Alice lives, Bob and Charlie endeavour to determine the month in which Alice was born. Bob is the first to meet Alice and asks the following question:

"How many letters are in the name of the month in which you were born, Alice?"

Alice responds with a number and Bob replies

"Hmm, I can't figure it out from that information alone. Is your birth month one of the first six months or the second six months?"

Again, Alice happily responds. Bob seems satisfied with this and declares

"Yes! I know the month in which you were born."

Later in the day, Charlie meets Alice and asks:

"What is the second letter of the month in which you were born?"

Alice responds with a letter and Charlie says

"Hmm, I can't figure it out from that information alone. How many days are there in the month of your birth this year?"

Again Alice replies. This is obviously enough for Charlie who also declares

"Eureka! I know in which month you were born."

As it happens, the month that Charlie thinks Alice was born is different to the month Bob thinks that Alice was born.

That night, Alice is recounting the story of the day with her friend, Doris. She tells her all the questions that were asked and includes her responses. She then tells Doris

"The funny thing is, exactly one of my answers to Bob was a lie and exactly one of my answers to Charlie was a lie."

This last statement is made truthfully.
Doris ponders this revelation for a moment and then declares

"Aha! I know in which month you were born."

In which month was Alice born?

$\endgroup$
  • 1
    $\begingroup$ Do Bob and Charlie get told the same month? I don't believe it works otherwise... $\endgroup$ – Nahmid Feb 12 at 16:12
  • $\begingroup$ @Nahmid The question has been edited based on your comment. $\endgroup$ – hexomino Feb 12 at 17:36
  • 1
    $\begingroup$ At what point will Bob and Charlie be creepy? (btw I like this question more than the other one, because it is not as ambiguous formulated as the other one) $\endgroup$ – findusl Feb 14 at 13:23
  • 1
    $\begingroup$ @findusl Thanks, once I cleaned up my mistakes it turned out well. $\endgroup$ – hexomino Feb 14 at 13:50
7
$\begingroup$

Alice was born in:

April


In Bob's questions, we find out that:

1. The common numbers that would make Bob unsure would be 4, 5, 7, and 8.
2. With presence in the first and later half of the calendar year, 5 (March and April) get removed as options
3. That leaves us with 4, 7, 8.

In Charlie's questions, we find out that:

1. The common second letters that would make Charlie unsure would be a, e, u.
2. With the number of months, it would be 31, 30, and 28.
3. Combining both of those, we end up with only four options: 31e: December, 30e: September, 30u: June, and 28e: February.

We are looking for answer combinations that give Bob and Charlie exactly one choice, but those choices have to be different.

Using some javascript to generate the combinations, and then painstakingly manually going through each one for Bob and Charlie's guesses...

Removing all combinations with substring u-28 due to their impossibility.
Removing all combinations with substring u-31 due to their ambiguity for Charlie.
Removing all combinations with substring 8-second due to their ambiguity for Bob.
Removing 4-first-u-30, 8-first-e-28 as these combinations end up with Bob and Charlie with the same guesses.

[4,7,8]x[first,second]x[e,u]x[28,30,31]: Bob's guess, Charlie's guess

4-first-e-28 - June, February
4-first-e-30 - June, September
4-first-e-31 - June, December
4-second-e-28 - July, February
4-second-e-30 - July, September
4-second-e-31 - July, December
4-second-u-30 - July, June
7-first-e-28 - January, February
7-first-e-30 - January, September
7-first-e-31 - January, December
7-first-u-30 - January, June
7-second-e-28 - October, February
7-second-e-30 - October, September
7-second-e-31 - October, December
7-second-u-30 - October, June
8-first-e-30 - February, September
8-first-e-31 - February, December
8-first-u-30 - February, June

We can further cross-check this with each of the "answer profiles" of all the months, and we can filter the list into all options with ONLY one similarity each for Bob and Charlie's questions to those month answer profiles.

Month answer profiles:

7-first-a-31 January
8-first-e-28 February
5-first-a-31 March
5-first-p-30 April
3-first-a-31 May
4-first-u-30 June
4-second-u-31 July
6-second-u-31 August
9-second-e-30 September
7-second-c-31 October
8-second-o-30 November
8-second-e-31 December

What remains are the following:

Alice's answers - Months that fit

4-first-e-30 - February, April
4-first-e-31 - January, February, March, May, July
4-second-e-28 - September, December
4-second-e-30 - June, November, December
4-second-e-31 - August, September, October
4-second-u-30 - August, September, November
7-first-e-30 - February, April, June
7-first-e-31 - February, March, May, October
7-first-u-30 - April
7-second-e-28 - September, December
7-second-e-30 - November, December
7-second-e-31 - January, July, August, September
7-second-u-30 - July, August, November
8-first-e-30 - April, June, November, December
8-first-e-31 - January, March, May, November, December
8-first-u-30 - April, November

Since Doris was sure without any further questions, the only option left for her would be to guess that Alice's birthday falls on...

April

The exact answers Alice gave to Bob and Charlie:

She told Bob that her birth month was 7 letters long (lie) and was in the first half of the calendar (truth), leading him to think it's January. She gave Charlie 'u' as the second letter (lie) and the month having 30 days (truth), leading him to think it's June.

|improve this answer|||||
$\endgroup$
  • 1
    $\begingroup$ This is the right answer, but I think there is a typo in the last paragraph, as June certainly does not have 7 letters. $\endgroup$ – Andrew Savinykh Feb 13 at 9:28
  • $\begingroup$ Brilliant, well done! It's much quicker to do your second step first ("answer profiles") and then check these for Bob/Charlie overlaps - this takes out the painstaking analysis. Andrew Savinykh is correct, the first June in the last paragraph should be replaced with January. $\endgroup$ – hexomino Feb 13 at 9:51
  • $\begingroup$ Yea @AndrewSavinykh he was meant to point to January the only on in the first 6 months with 7 letters...Also hinted by the point that Bob and Chris initially thought of 2 different months ... $\endgroup$ – eagle275 Feb 13 at 10:11
  • $\begingroup$ @Andrew, thanks. I missed that one. I did mean for it to be January. Edited now. $\endgroup$ – Zaenille Feb 13 at 10:12
  • $\begingroup$ Thanks @hexomino. While doing it, I could swear there's a more efficient way to solve this, but I was already done so I might as well leave it in :p $\endgroup$ – Zaenille Feb 13 at 10:20
6
$\begingroup$

Work in progress :

Months sorted by number of letters

3: May
4: June, July
5: March, April
6: August
7: January, October
8: February, November, December
9: September

Since Bob cannot guess from this point but can if he knows if it is one of the 6 first or last months,

we know that Alice answered either 4, 7 or 8. If she answered 8, we know that she answered it was during the first half.

Months sorted by second letter:

a: January, March, May
c: October
e: February, September, December
o: November
p: April
u: June, July, August

Since Charlie cannot guess from this point but can if he knows the number of days in the month,

we know that Alice either answered e or u. If she answered u, we know that she answered it has 30 months.

And now Doris know if Alice answered

4, 7 or 8 as well as e or u + both other information. Here are several table listing true/false for each month assuming Alice said:

 \ 8, first, u, 30 
January: F T F F
February: T T F F
March: F T F F
April: F T F T
May: F T F F
June: F T T T
July: F F T F
August: F F T F
September: F F F T
October: F F F F
November: T F F T
December: T F F F
b
So this assumption is wrong because April and November would be suitable to Alice having lied exactly once to Bob (April is not 8 letter whereas November is not in first half) and exactly once to Charlie (neither April nor November start by u), so Doris could not now which of the two it is.
 \ 4, first, u, 30 
January: F T F F
February: F T F F
March: F T F F
April: F T F T
May: F T F F
June: T T T T
July: T F T F
August: F F T F
September: F F F T
October: F F F F
November: F F F T
December: F F F F
b
So @thedude's answer is wrong because April and July would be suitable to Alice having lied exactly once to Bob (April is not 8 letter whereas July is not in first half) and exactly once to Charlie (April does not start by u whereas July does not have 30 days), so Doris could not now which of the two it is.
 \ 8, first, e, 30 
January: F T F F
February: T T T F
March: F T F F
April: F T F T
May: F T F F
June: F T F T
July: F F F F
August: F F F F
September: F F T T
October: F F F F
November: T F F T
December: T F T F
b
So @Van's assumption is wrong because April, June, November and December would be suitable to Alice having lied exactly once to Bob and exactly once to Charlie, so Doris could not now which of the four it is.
 \ 8, first, e, 28 
January: F T F F
February: T T T T
March: F T F F
April: F T F F
May: F T F F
June: F T F F
July: F F F F
August: F F F F
September: F F T F
October: F F F F
November: T F F F
December: T F T F
b
So @nahmid's assumption seems ok because only December would be suitable to Alice have lied exactly once to Bob (it is not in the first half) and exactly once to Charlie (it does not have 30 days). Is this solution unique? At least we can see that choosing the number of days has being 28 gives a column where all but one entries are false which is the only way to do so by construction.

Note that

there are 16 others possible assumptions (4 or 7 x 1st or 2nd x (e-28, e-30, e-31 or u).

|improve this answer|||||
$\endgroup$
  • 1
    $\begingroup$ Thank you for this analysis. Checking your analysis against my own has made me realise that there are in fact two distinct solutions (a typo in my working) and not one as I had previously thought. I will make a slight amendment to the question to distinguish but also give you an upvote. $\endgroup$ – hexomino Feb 12 at 17:04
  • $\begingroup$ If you persist with writing all the tables you will eventually determine the answer but there is a slightly quicker way to proceed, if you can find it. $\endgroup$ – hexomino Feb 12 at 17:58
4
$\begingroup$

This answer assumes that both Bob and Charlie got told the same month. I don't think the problem works if this assumption isn't met.

Alice was born in

December.

In Alice's first conversation with Bob, the two answers she gave must have been either:

4 letters (Jun/Jul), and either first half or second half
7 letters (Jan/Oct), and either first half or second half
8 letters (Feb/Nov/Dec), and first half

and so the months that Bob believes could be Alice's birthday month are:

Jun, Jul, Jan, Oct, or Feb.

In Alice's second conversation with Charlie, the two answers she gave must have been either:

Letter e (Feb/Sep/Dec), and 28, 30, or 31 days
Letter u (Jun/Jul/Aug), and 30 days

and so the months that Bob believes could be Alice's birthday month are:

Feb, Sep, Dec, or Jun.

The overlap, or the month that both Bob and Charlie believe to be the correct birthday month are then:

Jun: (4 letters, first half) and (Letter u, 30 days)
Feb: (8 letters, first half) and (Letter e, 28 days)

Suppose that the month that Bob and Charlie both got told was

June. We can see that both April and July fit the criterion for Alice lying exactly once to both people: for April, the lies were (4 letters, letter u), and for July, the lies were (first half, 30 days). Thus, Doris would not be able to differentiate between these.
This means that the month they both got told must have been February. Now if Alice was telling the truth about her month being in the first half, this means that it would have to be either Jan, Mar, Apr, May, Jun. However, none of these months have either second letter 'e' or 28 days, so this means that Alice must have lied in both her statements to Charlie.
Thus, Alice must have lied about her month being in the first half, and told the truth about her month having 8 letters. Given this, Alice must have lied about her month having 28 days to Charlie, since Feb is the only such month.
Of the months in the second half of the year with second letter 'e', the only one is December.

To recap,

Alice told Bob that her month had 8 letters and was in the first half of the year (lie), and told Charlie that the second letter was 'e' and had 28 days (lie).

|improve this answer|||||
$\endgroup$
  • $\begingroup$ That was my original thought, but if the lie is in the first answer to Bob or Charlie, I think this solution isn't the only one. $\endgroup$ – Herb Wolfe Feb 12 at 16:35
  • $\begingroup$ Thank you for this solution. Checking SMR's analysis against my own has made me realise that there are in fact two distinct solutions (a typo in my working) and not one as I had previously thought. I have made a slight amendment to the question to distinguish but also give you an upvote as this is a valid answer to the original question. Apologies for the mistake. $\endgroup$ – hexomino Feb 12 at 17:09
  • $\begingroup$ You beat me to it! $\endgroup$ – Van Feb 12 at 17:10
  • $\begingroup$ Your initial assumption was already excluded in the question ... Bob and Chris come to 2 different months after hearing the answers $\endgroup$ – eagle275 Feb 13 at 10:20
  • $\begingroup$ @eagle275 that was changed/clarified after this was posted. $\endgroup$ – Herb Wolfe Feb 14 at 15:51
2
$\begingroup$

Partial

Bob

Her first answer must have been one of

4, 7, 8

because

3, 6, and 9 are both unique answer, and if she'd said 5, his second question wouldn't have helped

The fact he knew the answer after the second question means she either said

4 followed by either answer; 7 followed by either answer; or 8 followed by 'first half', as they're the combinations that give a unique answer

Charlie

Her first answer must have been one of

e, u as they're the only non-unique options where the second question would have helped (all the a options have 31 days)

Then her second answer

must have been one of e/28, e/30, e/31, u/30 as they're the only unique options

Doris

If Doris knew the answer based on the given information, then

One answer from each set must be true, and they must only give a unique possibility.

At this point

I can't see how the question as currently asked has a unique answer knowable by Doris

|improve this answer|||||
$\endgroup$
  • $\begingroup$ SMR's answer above gives an indication on how some of the possibilities may be ruled out, although there is a quicker way to do this analysis. $\endgroup$ – hexomino Feb 12 at 17:28
  • $\begingroup$ But that relies on Doris knowing that rot13(gur vasbezngvba fur'f orra tvira vf rabhtu gb tvir ure n havdhr nafjre)? $\endgroup$ – Mohirl Feb 12 at 17:31
  • $\begingroup$ If the information given to her does not lead to a unique answer then she won't know the month, will she? $\endgroup$ – hexomino Feb 12 at 17:32
  • $\begingroup$ rot13(Qbevf qbrfa'g erwrpg gur nafjre frg, jr qb orpnhfr Qbevf qbrfa'g xabj. Pbafvqre gur svefg bs FZE'f gnoyrf. Vs gung vf gur vasbezngvba Qbevf vf cerfragrq jvgu, gura gur ovegu zbagu vf rvgure Ncevy be Abirzore. Ohg gura Qbevf pnaabg xabj juvpu bar vg vf. Urapr guvf vf abg gur nafjre frg cerfragrq gb Qbevf.) $\endgroup$ – hexomino Feb 12 at 17:52
  • $\begingroup$ You see, you also omitted the key fact that I'm an idiot!! I missed the fact that Doris knew the answers. I was trying to do it if Doris didn't know the answers, but knew that she knew enough to know. Which I think still works out as the same puzzle.I'm going to delete my comments under the question as they're just clogging things up $\endgroup$ – Mohirl Feb 12 at 18:03
2
$\begingroup$

Alice was born in

February of a leap year.

Alice first tells Bob that

there are either 4 or 7 letters (lie, there are actually 8).

This narrows down Bob's list to

June and July if she said 4, or January and October if she said 7.

Alice then tells Bob that

it's in the first 6 months (truth).

As a result, Bob thinks that Alice was born in

either January or June (incorrectly), depending on Alice's first answer.

Alice first tells Charlie that

the second letter is "e" (truth).

This narrows down Charlie's list to

February, September, and December.

Alice then tells Charlie that

there are 28 days (lie, there are actually 29).

As a result, Charlie thinks that Alice was born in

February (correctly, despite the lie).

|improve this answer|||||
$\endgroup$
  • $\begingroup$ Ah, very sneaky. I avoided being specific on this because it makes Charlie's second question syntactically awkward and presumably Alice's response would be something along the lines of "28 or 29, depending" but I take your point. I want to edit the question one more time but will tighten up Charlie's question in the process. $\endgroup$ – hexomino Feb 13 at 9:58
2
$\begingroup$

The answer is:

April

Explanation:

Month............Num. letters.........Second letter..........Number of days
January..............7........................A............................31
February.............8........................E...........................28
March.................5........................A...........................31
April....................5........................P...........................30
May.....................3........................A...........................31
June....................4........................U...........................30
July......................4........................U...........................31
August.................6........................U...........................31
September...........9........................E...........................30
October................7........................C...........................31
November............8........................O...........................30
December............8........................E...........................31

In the conversation with Bob, we can assume that the number given is non-unique and related to at least a month in each half. The only numbers satisfying these conditions are 4, 7 and 8 (being generous).

In the conversation with Charlie, we can assume that the letter given is non-unique and related to months with different numbers of days in them. The only letters satisfying these conditions are E and U. Let's lay out the possible results:

..........1st half...........2nd half
4........June...............July
7........January...........October
8........February.........November/December (unsolvable for Bob)
Other..Mar/Apr/May...August/September

...........28.........................30............................31
E........February..............September...............December
U...........X.........................June.....................July/August (unsolvable for Charlie)
Other.....X......................Apr/Nov...................Jan/March/May/Oct

The possible correct months for any month given:

(1) Jun: Jul, Jan, Feb, Mar, Apr, May
(2) Jul: Jun, Oct, Nov, Dec, Aug, Sep
(3) Jan: Oct, Jun, Feb, Mar, Apr, May
(4) Oct: Jan, Jul, Nov, Dec, Aug, Sep
(5) Feb: Nov, Dec, Jun, Jan, Mar, Apr, May

(a) Feb: Sep, Dec
(b) Sep: Feb, Dec, Jun, Apr, Nov
(c) Dec: Feb, Sep, Jul, Aug, Jan, Mar, May, Oct
(d) Jun: Jul, Aug, Apr, Nov, Sep

The only combination with two different months and only one common month is 3d (Jan and Jun, the right month being April).

|improve this answer|||||
$\endgroup$
  • $\begingroup$ So if Bob assumes February, then he must have given 8 and first half. If Charlie assumes September then he must have been given 30 and E. If both are told one lie then December is a valid answer but so is November so Doris wouldn't be able to distinguish between these two. $\endgroup$ – hexomino Feb 13 at 19:42
  • $\begingroup$ Edited my answer. $\endgroup$ – Nautilus Feb 14 at 8:52
  • $\begingroup$ yes, this is it! +1 $\endgroup$ – hexomino Feb 14 at 9:54
1
$\begingroup$

Many questions that allow brute forcing have an obligatory answer "I wrote a program!". Those are usually less fun to read, than logical reasoning, but for some people (including me) they are a great fun to write. So, here we go, C#. Below moslty follows the reasoning in SMR's answer.

Try it online!

using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;

static class Program
{
  static Func<int, string>[] lambdas => new Func<int, string>[] {
      // First Bob's Question: "How many letters are in the name of the month?"
        (m => CultureInfo.InvariantCulture.DateTimeFormat.GetMonthName(m).Length.ToString()),
      // Second Bob's Question: "Is it one of the first six months or the second six months?"
      (m => (m <= 6).ToString()),
      // First Charlies's Question: "What is the second letter of the month?"
      (m => CultureInfo.InvariantCulture.DateTimeFormat.GetMonthName(m)[1].ToString()),
      // Second Charlies's Question: "How many days are there in the month"
      // Note, for February we do not care if it's 28 or 29, since in any case it differs from all other months
      (m => DateTime.DaysInMonth(1, m).ToString())
    };

  static void Main()
  {

    var months = Enumerable.Range(1, 12);

    // Enumerate all possible answers for each of the four questions
    var arrays = lambdas.Select(l => months.Select(l).Distinct().ToArray()).ToArray();

    // For brute forcing let's count up the number of all different answers combinations from Alice
    int total = arrays.Aggregate(1, (x, y) => x * y.Length);

    for (int i = 0; i < total; i++)
    {
      // Get current possible answers combination
      string[] answers = GetPossibleAnswers(arrays, i);

      var monthsLeftAfterFirstBobsAnswer = months.Where(m => CheckBobsFirstAnswer(answers, m));
      var monthsLeftAfterSecondBobsAnswer = monthsLeftAfterFirstBobsAnswer.Where(m => CheckBobsSecondAnswer(answers, m));
      var monthsLeftAfterFirstCharliesAnswer = months.Where(m => CheckCharliesFirstAnswer(answers, m));
      var monthsLeftAfterSecondCharliesAnswer = monthsLeftAfterFirstCharliesAnswer.Where(m => CheckCharliesSecondAnswer(answers, m));

      if (
        // We know that Bob could not tell the answer after his first question
        !(monthsLeftAfterFirstBobsAnswer.Count() > 1
        // But could after his second
        && monthsLeftAfterSecondBobsAnswer.Count() == 1
        // We know that Charlie could not tell the answer after his first question
        && monthsLeftAfterFirstCharliesAnswer.Count() > 1
        // But could after his second
        && monthsLeftAfterSecondCharliesAnswer.Count() == 1
        // And the month the Bob got is different from the one Charlie got
        && monthsLeftAfterSecondBobsAnswer.Single() != monthsLeftAfterSecondCharliesAnswer.Single()
        ))
      {
        continue;
      }

      // At this point we know that the current answers combination is something that would
      // satisfy both Bob and Charlie, and they have different months in mind

      // Now let's deal with Doris
      // In this list we will collect all months that for the current set of answers
      // Would make exactly one answer to Bob a lie and exacly one answer to Charile a lie
      List<int> candidateMonths = new List<int>();

      foreach (var m in months)
      {
        if (CheckBobsFirstAnswer(answers, m) != CheckBobsSecondAnswer(answers, m)
          && CheckCharliesFirstAnswer(answers, m) != CheckCharliesSecondAnswer(answers, m))
        {
          candidateMonths.Add(m);
        }
      }

      // Doris could only figure out the right month, if there was only a single month, for which
      // the answers combination give exactly one lie to in answer to Bob's questions and likewise for Charlie
      if (candidateMonths.Count == 1)
      {
        // And this is the Alice's Birth month then!
        Console.WriteLine(CultureInfo.InvariantCulture.DateTimeFormat.GetMonthName(candidateMonths[0]));
      }
    }
  }

  // As iteration parameter goes from 0 to max, this method enumerates all possible
  // answer combinations Alice could give to Bob and Charlie
  static string[] GetPossibleAnswers(string[][] arrays, int iteration)
  {
    string[] result = new string[arrays.Length];
    for (int i = 0; i < arrays.Length; i++)
    {
      int modulo = arrays[i].Length;
      result[i] = arrays[i][iteration % modulo];
      iteration = iteration / modulo;
    }
    return result;
  }

  // Check if an Answer to one of the Guy's question is truthful, if Alice's birthday is in given month
  static bool CheckAnswer(string[] answers, int question, int month)
  {
    return lambdas[question](month) == answers[question];
  }
  static Func<string[], int, bool> CheckBobsFirstAnswer = (answers, month) => CheckAnswer(answers, 0, month);
  static Func<string[], int, bool> CheckBobsSecondAnswer = (answers, month) => CheckAnswer(answers, 1, month);
  static Func<string[], int, bool> CheckCharliesFirstAnswer = (answers, month) => CheckAnswer(answers, 2, month);
  static Func<string[], int, bool> CheckCharliesSecondAnswer = (answers, month) => CheckAnswer(answers, 3, month);
}
|improve this answer|||||
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.