Add files via upload

This commit is contained in:
Peter Norvig
2017-09-19 19:36:36 -07:00
committed by GitHub
parent a063aae475
commit 0fe7ca926c

View File

@@ -1150,55 +1150,10 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"We see that out of these 8 possibilities, if the number of people in the room (the last number in each tuple) \n",
"We see that out of these 7 possibilities, if the number of people in the room (the last number in each tuple) \n",
"were anything other than 13, then the friend (who can observe the number of people in the room) would know the ages. Since the `friend2` statement professes continued ignorance, it must be that the number of people in the room is 13. Then the `parent3` statement makes it clear that there can't be 6-year-old twins as the oldest children; it must be 2-year-old twins with an oldest age 9."
]
},
{
"cell_type": "code",
"execution_count": 34,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{('B', 'B', 'W'),\n",
" ('B', 'W', 'B'),\n",
" ('B', 'W', 'W'),\n",
" ('W', 'B', 'W'),\n",
" ('W', 'W', 'B'),\n",
" ('W', 'W', 'W')}"
]
},
"execution_count": 34,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import itertools\n",
"\n",
"states = {(a, b, c) \n",
" for a in 'BW' for b in 'BW' for c in 'BW' \n",
" if not (a == b == c == 'B')}\n",
"\n",
"def logical_hats(states):\n",
" return hear(states, response1, resonse2, response3)\n",
" \n",
"def no_response(states):\n",
" \"There is no response if no logician has a \"\n",
" \n",
"def response1(state): \n",
" (a, b, c) = state\n",
" return not (b == c == 'B')\n",
"\n",
"def response2(state):\n",
" True\n",
" \n",
"\n",
"hear(states, response1)"
]
},
{
"cell_type": "markdown",
"metadata": {},