Add files via upload
This commit is contained in:
@@ -100,7 +100,7 @@
|
||||
"# the month and the day of the birthday respectively.\n",
|
||||
"\n",
|
||||
"def tell(part):\n",
|
||||
" \"Cheryl tells a part of her birthdate; return a new set of possible dates that match the part.\"\n",
|
||||
" \"Cheryl tells a part of her birthdate; return a subset of DATES that match the part.\"\n",
|
||||
" return {date for date in DATES if part in date}\n",
|
||||
"\n",
|
||||
"def know(possible_dates):\n",
|
||||
@@ -502,13 +502,13 @@
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"def cheryls_birthday_with_eve(dates):\n",
|
||||
" \"Return a list of the possible dates for which Albert, Bernard, and Eve's statements are true.\"\n",
|
||||
" \"Return a set of the dates for which Albert, Bernard, and Eve's statements are true.\"\n",
|
||||
" return hear(using(dates), albert1, bernard1, albert2, eve1)\n",
|
||||
"\n",
|
||||
"def eve1(date):\n",
|
||||
" \"\"\"Eve: I peeked and saw the first letter of the month and the first digit of the day. \n",
|
||||
" When I peeked, I didn't know Cheryl's birthday, but after listening to Albert and Bernard I do. \n",
|
||||
" And it's a good thing I peeked, because otherwise I couldn't have figured it out.\"\"\"\n",
|
||||
" When I peeked, I didn't know Cheryl's birthday, but after listening to Albert and Bernard \n",
|
||||
" I do. And it's a good thing I peeked, because otherwise I couldn't have figured it out.\"\"\"\n",
|
||||
" at_first = tell(first(day(date))) & tell(first(month(date)))\n",
|
||||
" otherwise = tell('')\n",
|
||||
" return (not know(at_first) and\n",
|
||||
@@ -630,7 +630,7 @@
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"def cheryls_birthday_complex(dates):\n",
|
||||
" \"Return a list of the possible dates for which Albert, Bernard, and Eve's statements are true.\"\n",
|
||||
" \"Return a set of the dates for which Albert, Bernard, and Eve's statements are true.\"\n",
|
||||
" return hear(using(dates), albert1, bernard1, albert2c, eve1c, albert3c)\n",
|
||||
"\n",
|
||||
"def albert2c(date):\n",
|
||||
@@ -639,8 +639,8 @@
|
||||
"\n",
|
||||
"def eve1c(date):\n",
|
||||
" \"\"\"Eve: I peeked and saw the first letter of the month and the first digit of the day. \n",
|
||||
" When I peeked, I didn't know Cheryl's birthday, but after listening to Albert and Bernard I do. \n",
|
||||
" And it's a good thing I peeked, because otherwise I couldn't have figured it out.\"\"\"\n",
|
||||
" When I peeked, I didn't know Cheryl's birthday, but after listening to Albert and Bernard \n",
|
||||
" I do. And it's a good thing I peeked, because otherwise I couldn't have figured it out.\"\"\"\n",
|
||||
" at_first = tell(first(day(date))) & tell(first(month(date)))\n",
|
||||
" otherwise = tell('')\n",
|
||||
" return (not know(at_first)\n",
|
||||
|
||||
Reference in New Issue
Block a user