Cheryl's birthday: Difference between revisions

Content added Content deleted
m (added whitespace to the task's preamble, changed order of related task and references, corrected a misspelling.)
Line 3: Line 3:
Albert and Bernard just became friends with Cheryl, and they want to know when her birthday is.
Albert and Bernard just became friends with Cheryl, and they want to know when her birthday is.


Cheryl gave them a list of 10 possible dates:
Cheryl gave them a list of ten possible dates:
May 15, May 16, May 19

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


Cheryl then tells Albert and Bernard separately the month and the day of the birthday respectively.
Cheryl then tells Albert and Bernard separately the month and the day of the birthday respectively.
1) Albert: I don't know when Cheryl's birthday is, but I know that Bernard does not know too.
2) Bernard: At first I don't know when Cheryl's birthday is, but I know now.
3) Albert: Then I also know when Cheryl's birthday is.


1) Albert: I don't know when Cheryl's birthday is, but I know that Bernard does not know too.


;Task
2) Bernard: At first I don't know when Cheryl's birthday is, but I know now.
Write a computer program to deduce, by successive elimination, Cheryl's birthday.


3) Albert: Then I also know when Cheryl's birthday is.


;Related task:
* [[Sum and Product Puzzle]]


;Task


;References
Write a program in your language to deduce, by successive elimination, Cheryl's birthday.
;Referrences
* [https://en.wikipedia.org/wiki/Cheryl%27s_Birthday Wikipedia article] of the same name.
* [https://en.wikipedia.org/wiki/Cheryl%27s_Birthday Wikipedia article] of the same name.
* [https://en.wikipedia.org/wiki/Tuple_relational_calculus, Tuple Relational Calculus]
* [https://en.wikipedia.org/wiki/Tuple_relational_calculus, Tuple Relational Calculus]

;Related task:
* [[Sum and Product Puzzle]]
<br><br>
<br><br>