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