Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A Jupyter notebook for the "Lion and Unicorn" puzzle (puzzle 47) in "What is the Name of This Book?" By Raymond Smullyan
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# The Forest of Forgetfulness\n",
"\n",
"A workbook for \"The Forest of Forgetfulness\" puzzles, as described in *What is the Name of This Book?* by Raymond Smullyan."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## The Lion and the Unicorn\n",
"When Alice entered the Forest of Forgetfulness, she did not forget *everything*, only certain things. She often forgot her name, and the one thing she was most likely to forget was the day of the week. Now, the Lion and the Unicorn were frequent visitors to the forest. These two are strange creatures. The Lion lies on **Mondays**, **Tuesdays**, and **Wednesdays**, and tells the truth on the other days of the week. The Unicorn, on the other hand, lies on **Thursdays**, **Fridays**, and **Saturdays**, but tells the truth on other days of the week."
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']\n"
]
}
],
"source": [
"# first we define the days of the week\n",
"daysOfWeek = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']\n",
"print(daysOfWeek)"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"# if we say one of several days was yesterday, return the possible days for 'today'\n",
"def fromYesterdays(yesterdays):\n",
" return [daysOfWeek[(daysOfWeek.index(day) + 1) % (len(daysOfWeek))] for day in yesterdays]"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['Wednesday', 'Monday']"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"fromYesterdays(['Tuesday','Sunday'])"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"# if we say one of several days will be tomorrow, return the possible days for 'today'\n",
"def fromTomorrows(tomorrows):\n",
" return [daysOfWeek[(daysOfWeek.index(day) - 1) % (len(daysOfWeek))] for day in tomorrows]\n",
" "
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['Sunday', 'Monday', 'Saturday']"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"fromTomorrows(['Monday','Tuesday','Sunday'])"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"# as mentioned above, these creatures lie on certain days\n",
"lionLying =['Monday', 'Tuesday', 'Wednesday']\n",
"unicornLying = ['Thursday', 'Friday','Saturday']"
]
},
{
"cell_type": "code",
"execution_count": 34,
"metadata": {},
"outputs": [],
"source": [
"# given a list of days, what are the other days of the week?\n",
"def otherDays(days):\n",
" return [day for day in daysOfWeek if day not in days]"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"otherDays(['Monday'])"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
"# we can find when the Lion and Unicorn are truthful\n",
"lionTruthful = otherDays(lionLying)\n",
"unicornTruthful = otherDays(unicornLying)"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['Thursday', 'Friday', 'Saturday', 'Sunday']\n"
]
}
],
"source": [
"print(lionTruthful)"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
"# return the days of the week that are common to both lists\n",
"def intersect(a, b):\n",
" return [item for item in a if item in b]\n",
" \n",
"# return the days of the week that appear in either list\n",
"def union(a, b):\n",
" return list(a) + [item for item in b if item not in a]\n",
" "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"There is only one day where the Lion and the Unicorn are both truthful."
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['Sunday']"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"intersect(lionTruthful,unicornTruthful)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"There is no day when they are both lying"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[]"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"intersect(lionLying, unicornLying )"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Put another way, they are lying most of the week - only Sunday is a day where there is no lying."
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']\n"
]
}
],
"source": [
"print(union(lionLying, unicornLying))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"But everyday someone is telling the truth"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['Thursday', 'Friday', 'Saturday', 'Sunday', 'Monday', 'Tuesday', 'Wednesday']"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"union(lionTruthful, unicornTruthful)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Problem 1\n",
"One day Alice met the Lion and the Unicorn resting under a tree. They made the following statements:\n",
"> **Lion**: Yesterday was one of my lying days.\n",
"\n",
"> **Unicorn**: Yesterday was one of my lying days too."
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"lion could be saying this on ['Thursday', 'Monday']\n",
"unicorn could be saying this on ['Sunday', 'Thursday']\n",
"the solution is that today is Thursday\n"
]
}
],
"source": [
"lionPositive = intersect(fromYesterdays(lionLying), lionTruthful)\n",
"lionNegative = intersect(otherDays(fromYesterdays(lionLying)), lionLying)\n",
"lionDays = union(lionPositive, lionNegative)\n",
"unicornPositive = intersect(fromYesterdays(unicornLying), unicornTruthful)\n",
"unicornNegative = intersect(otherDays(fromYesterdays(unicornLying)),unicornLying)\n",
"unicornDays = union(unicornPositive, unicornNegative)\n",
"print('lion could be saying this on ' + str(lionDays))\n",
"print('unicorn could be saying this on ' + str(unicornDays))\n",
"validDays = intersect(lionDays, unicornDays)\n",
"if (len(validDays) == 1):\n",
" print('the solution is that today is ' + validDays[0])\n",
"else :\n",
" print('there is no unique solution, it could be one of these ' + str(validDays))"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [],
"source": [
"# let's make the process above into a function\n",
"def solve(lionStatement, unicornStatement):\n",
" lionPositive = intersect(lionStatement, lionTruthful)\n",
" lionNegative = intersect(otherDays(lionStatement), lionLying)\n",
" lionDays = union(lionPositive, lionNegative)\n",
" unicornPositive = intersect(unicornStatement, unicornTruthful)\n",
" unicornNegative = intersect(otherDays(unicornStatement),unicornLying)\n",
" unicornDays = union(unicornPositive, unicornNegative)\n",
" print('The lion could be saying this on ' + str(lionDays))\n",
" print('The unicorn could be saying this on ' + str(unicornDays))\n",
" validDays = intersect(lionDays, unicornDays)\n",
" if (len(validDays) == 1):\n",
" print('So, the solution is that today is ' + validDays[0])\n",
" else :\n",
" print('Unfortunately, there is no unique solution, it could be one of these ' + str(validDays))\n",
" "
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The lion could be saying this on ['Thursday', 'Monday']\n",
"The unicorn could be saying this on ['Sunday', 'Thursday']\n",
"So, the solution is that today is Thursday\n"
]
}
],
"source": [
"solve(fromYesterdays(lionLying), fromYesterdays(unicornLying))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Problem 2\n",
"One day Alice met the Lion and the Unicorn resting under a tree. They made the following statements:\n",
"> Lion: Yesterday was one of my truthful days.\n",
"\n",
"> Unicorn: Yesterday was one of my truthful days too."
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The lion could be saying this on ['Friday', 'Saturday', 'Sunday', 'Tuesday', 'Wednesday']\n",
"The unicorn could be saying this on ['Tuesday', 'Wednesday', 'Monday', 'Friday', 'Saturday']\n",
"Unfortunately, there is no unique solution, it could be one of these ['Friday', 'Saturday', 'Tuesday', 'Wednesday']\n"
]
}
],
"source": [
"solve(fromYesterdays(lionTruthful), fromYesterdays(unicornTruthful))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Problem 3\n",
"One day Alice met the Lion and the Unicorn resting under a tree. They made the following statements:\n",
"> Lion: Yesterday was one of my truthful days.\n",
"\n",
"> Unicorn: Yes, yesterday was one of Lion's truthful days"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The lion could be saying this on ['Friday', 'Saturday', 'Sunday', 'Tuesday', 'Wednesday']\n",
"The unicorn could be saying this on ['Sunday', 'Monday', 'Thursday']\n",
"So, the solution is that today is Sunday\n"
]
}
],
"source": [
"solve(fromYesterdays(lionTruthful), fromYesterdays(lionTruthful))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Problem 4\n",
"One day Alice met the Lion and the Unicorn resting under a tree. They made the following statements:\n",
"> Lion: Yesterday was one of my truthful days.\n",
"\n",
"> Unicorn: Actually, it was one of his lying days"
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The lion could be saying this on ['Friday', 'Saturday', 'Sunday', 'Tuesday', 'Wednesday']\n",
"The unicorn could be saying this on ['Tuesday', 'Wednesday', 'Friday', 'Saturday']\n",
"Unfortunately, there is no unique solution, it could be one of these ['Friday', 'Saturday', 'Tuesday', 'Wednesday']\n"
]
}
],
"source": [
"solve(fromYesterdays(lionTruthful), fromYesterdays(lionLying))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Problem 5\n",
"One day Alice met the Lion and the Unicorn resting under a tree. They made the following statements:\n",
"> Lion: Tomorrow is one of my truthful days.\n",
"\n",
"> Unicorn: Yesterday was one of my lying days."
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The lion could be saying this on ['Thursday', 'Friday', 'Saturday', 'Monday', 'Tuesday']\n",
"The unicorn could be saying this on ['Sunday', 'Thursday']\n",
"So, the solution is that today is Thursday\n"
]
}
],
"source": [
"solve(fromTomorrows(lionTruthful), fromYesterdays(unicornLying))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# All Possible Puzzles\n",
"Using these puzzles as a model, we can have the Lion and the Unicorn make a statement about either yesterday, today, or tomorrow being one of the lying or truthful days for themselves, or the other."
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[['Monday', 'Tuesday', 'Wednesday'], ['Sunday', 'Monday', 'Tuesday'], ['Tuesday', 'Wednesday', 'Thursday'], ['Thursday', 'Friday', 'Saturday', 'Sunday'], ['Wednesday', 'Thursday', 'Friday', 'Saturday'], ['Friday', 'Saturday', 'Sunday', 'Monday'], ['Thursday', 'Friday', 'Saturday'], ['Wednesday', 'Thursday', 'Friday'], ['Friday', 'Saturday', 'Sunday'], ['Monday', 'Tuesday', 'Wednesday', 'Sunday'], ['Sunday', 'Monday', 'Tuesday', 'Saturday'], ['Tuesday', 'Wednesday', 'Thursday', 'Monday']]\n",
"\n",
"There are 12 possible statements each creature can make.\n"
]
}
],
"source": [
"# let's define a function to help us generate all the different lists of days that might be talked about\n",
"def variations(statements):\n",
" return [statements, fromTomorrows(statements), fromYesterdays(statements)]\n",
"\n",
"# now create a list of lists\n",
"allDays = [];\n",
"allDays.extend(variations(lionLying))\n",
"allDays.extend(variations(lionTruthful))\n",
"allDays.extend(variations(unicornLying))\n",
"allDays.extend(variations(unicornTruthful))\n",
"\n",
"print(allDays)\n",
"print()\n",
"print('There are ' + str(len(allDays)) + ' possible statements each creature can make.')"
]
},
{
"cell_type": "code",
"execution_count": 24,
"metadata": {},
"outputs": [],
"source": [
"# a variation on the solve function that j# let's make the process above into a function\n",
"def hasSolution(lionStatement, unicornStatement):\n",
" lionPositive = intersect(lionStatement, lionTruthful)\n",
" lionNegative = intersect(otherDays(lionStatement), lionLying)\n",
" lionDays = union(lionPositive, lionNegative)\n",
" unicornPositive = intersect(unicornStatement, unicornTruthful)\n",
" unicornNegative = intersect(otherDays(unicornStatement),unicornLying)\n",
" unicornDays = union(unicornPositive, unicornNegative)\n",
" validDays = intersect(lionDays, unicornDays)\n",
" return (len(validDays) == 1)\n"
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"False"
]
},
"execution_count": 25,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# test the above\n",
"hasSolution(fromTomorrows(lionTruthful), fromYesterdays(lionLying))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can loop through all combinations of the Lion and Unicorn making each statement, and apply this function to each."
]
},
{
"cell_type": "code",
"execution_count": 26,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"We found 43 puzzles with solutions out of 144 possible combinations\n"
]
}
],
"source": [
"solutionCount = 0\n",
"totalCount = 0\n",
"for s1 in allDays:\n",
" for s2 in allDays:\n",
" totalCount = totalCount + 1\n",
" if hasSolution(s1,s2):\n",
" solutionCount = solutionCount + 1\n",
"print('We found ' + str(solutionCount) + ' puzzles with solutions out of ' + str(totalCount) +' possible combinations') "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Let's write some utilities to print out all the valid puzzle statements and solutions."
]
},
{
"cell_type": "code",
"execution_count": 27,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[{'days': ['Monday', 'Tuesday', 'Wednesday'],\n",
" 'description': 'Lion told lies today'},\n",
" {'days': ['Sunday', 'Monday', 'Tuesday'],\n",
" 'description': 'Lion will tell lies tomorrow'},\n",
" {'days': ['Tuesday', 'Wednesday', 'Thursday'],\n",
" 'description': 'Lion told lies yesterday'},\n",
" {'days': ['Thursday', 'Friday', 'Saturday', 'Sunday'],\n",
" 'description': 'Lion told truths today'},\n",
" {'days': ['Wednesday', 'Thursday', 'Friday', 'Saturday'],\n",
" 'description': 'Lion will tell truths tomorrow'},\n",
" {'days': ['Friday', 'Saturday', 'Sunday', 'Monday'],\n",
" 'description': 'Lion told truths yesterday'},\n",
" {'days': ['Thursday', 'Friday', 'Saturday'],\n",
" 'description': 'Unicorn told lies today'},\n",
" {'days': ['Wednesday', 'Thursday', 'Friday'],\n",
" 'description': 'Unicorn will tell lies tomorrow'},\n",
" {'days': ['Friday', 'Saturday', 'Sunday'],\n",
" 'description': 'Unicorn told lies yesterday'},\n",
" {'days': ['Monday', 'Tuesday', 'Wednesday', 'Sunday'],\n",
" 'description': 'Unicorn told truths today'},\n",
" {'days': ['Sunday', 'Monday', 'Tuesday', 'Saturday'],\n",
" 'description': 'Unicorn will tell truths tomorrow'},\n",
" {'days': ['Tuesday', 'Wednesday', 'Thursday', 'Monday'],\n",
" 'description': 'Unicorn told truths yesterday'}]"
]
},
"execution_count": 27,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"def annotatedVariations(base):\n",
" today = {'description': base['actor'] + ' told ' + base['state'] + ' today', 'days': base['days']}\n",
" tomorrow = {'description': base['actor'] + ' will tell ' + base['state'] + ' tomorrow', 'days': fromTomorrows(base['days'])}\n",
" yesterday = {'description': base['actor'] +' told ' + base['state'] + ' yesterday', 'days': fromYesterdays(base['days'])}\n",
" return [today, tomorrow, yesterday]\n",
"\n",
"allAnnotated = [];\n",
"allAnnotated.extend(annotatedVariations({'actor': 'Lion', 'state': 'lies', 'days': lionLying}))\n",
"allAnnotated.extend(annotatedVariations({'actor': 'Lion', 'state': 'truths', 'days': lionTruthful}))\n",
"allAnnotated.extend(annotatedVariations({'actor': 'Unicorn', 'state': 'lies', 'days': unicornLying}))\n",
"allAnnotated.extend(annotatedVariations({'actor': 'Unicorn', 'state': 'truths', 'days': unicornTruthful}))\n",
"allAnnotated"
]
},
{
"cell_type": "code",
"execution_count": 28,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Puzzle 1\n",
"The Lion says: I will tell lies tomorrow.\n",
"The Unicorn says: Lion told lies today.\n",
"SOLUTION: Today is Wednesday\n",
"--------------\n",
"\n",
"Puzzle 2\n",
"The Lion says: I will tell lies tomorrow.\n",
"The Unicorn says: Lion will tell lies tomorrow.\n",
"SOLUTION: Today is Sunday\n",
"--------------\n",
"\n",
"Puzzle 3\n",
"The Lion says: I will tell lies tomorrow.\n",
"The Unicorn says: Lion told lies yesterday.\n",
"SOLUTION: Today is Wednesday\n",
"--------------\n",
"\n",
"Puzzle 4\n",
"The Lion says: I will tell lies tomorrow.\n",
"The Unicorn says: Lion told truths today.\n",
"SOLUTION: Today is Sunday\n",
"--------------\n",
"\n",
"Puzzle 5\n",
"The Lion says: I will tell lies tomorrow.\n",
"The Unicorn says: Lion will tell truths tomorrow.\n",
"SOLUTION: Today is Wednesday\n",
"--------------\n",
"\n",
"Puzzle 6\n",
"The Lion says: I will tell lies tomorrow.\n",
"The Unicorn says: Lion told truths yesterday.\n",
"SOLUTION: Today is Sunday\n",
"--------------\n",
"\n",
"Puzzle 7\n",
"The Lion says: I will tell lies tomorrow.\n",
"The Unicorn says: I will tell lies tomorrow.\n",
"SOLUTION: Today is Wednesday\n",
"--------------\n",
"\n",
"Puzzle 8\n",
"The Lion says: I will tell lies tomorrow.\n",
"The Unicorn says: I told lies yesterday.\n",
"SOLUTION: Today is Sunday\n",
"--------------\n",
"\n",
"Puzzle 9\n",
"The Lion says: I will tell lies tomorrow.\n",
"The Unicorn says: I will tell truths tomorrow.\n",
"SOLUTION: Today is Sunday\n",
"--------------\n",
"\n",
"Puzzle 10\n",
"The Lion says: I will tell lies tomorrow.\n",
"The Unicorn says: I told truths yesterday.\n",
"SOLUTION: Today is Wednesday\n",
"--------------\n",
"\n",
"Puzzle 11\n",
"The Lion says: I told lies yesterday.\n",
"The Unicorn says: I told lies yesterday.\n",
"SOLUTION: Today is Thursday\n",
"--------------\n",
"\n",
"Puzzle 12\n",
"The Lion says: I told lies yesterday.\n",
"The Unicorn says: I told truths yesterday.\n",
"SOLUTION: Today is Monday\n",
"--------------\n",
"\n",
"Puzzle 13\n",
"The Lion says: I told truths today.\n",
"The Unicorn says: Lion told truths today.\n",
"SOLUTION: Today is Sunday\n",
"--------------\n",
"\n",
"Puzzle 14\n",
"The Lion says: I told truths today.\n",
"The Unicorn says: Lion will tell truths tomorrow.\n",
"SOLUTION: Today is Wednesday\n",
"--------------\n",
"\n",
"Puzzle 15\n",
"The Lion says: I will tell truths tomorrow.\n",
"The Unicorn says: I will tell lies tomorrow.\n",
"SOLUTION: Today is Saturday\n",
"--------------\n",
"\n",
"Puzzle 16\n",
"The Lion says: I will tell truths tomorrow.\n",
"The Unicorn says: I told lies yesterday.\n",
"SOLUTION: Today is Thursday\n",
"--------------\n",
"\n",
"Puzzle 17\n",
"The Lion says: I told truths yesterday.\n",
"The Unicorn says: Lion told truths today.\n",
"SOLUTION: Today is Sunday\n",
"--------------\n",
"\n",
"Puzzle 18\n",
"The Lion says: I told truths yesterday.\n",
"The Unicorn says: Lion will tell truths tomorrow.\n",
"SOLUTION: Today is Wednesday\n",
"--------------\n",
"\n",
"Puzzle 19\n",
"The Lion says: I told truths yesterday.\n",
"The Unicorn says: Lion told truths yesterday.\n",
"SOLUTION: Today is Sunday\n",
"--------------\n",
"\n",
"Puzzle 20\n",
"The Lion says: I told truths yesterday.\n",
"The Unicorn says: I told lies yesterday.\n",
"SOLUTION: Today is Sunday\n",
"--------------\n",
"\n",
"Puzzle 21\n",
"The Lion says: Unicorn told lies today.\n",
"The Unicorn says: Lion will tell truths tomorrow.\n",
"SOLUTION: Today is Wednesday\n",
"--------------\n",
"\n",
"Puzzle 22\n",
"The Lion says: Unicorn told lies today.\n",
"The Unicorn says: I told lies yesterday.\n",
"SOLUTION: Today is Thursday\n",
"--------------\n",
"\n",
"Puzzle 23\n",
"The Lion says: Unicorn will tell lies tomorrow.\n",
"The Unicorn says: I told lies yesterday.\n",
"SOLUTION: Today is Thursday\n",
"--------------\n",
"\n",
"Puzzle 24\n",
"The Lion says: Unicorn told lies yesterday.\n",
"The Unicorn says: Lion told truths today.\n",
"SOLUTION: Today is Sunday\n",
"--------------\n",
"\n",
"Puzzle 25\n",
"The Lion says: Unicorn told lies yesterday.\n",
"The Unicorn says: Lion will tell truths tomorrow.\n",
"SOLUTION: Today is Wednesday\n",
"--------------\n",
"\n",
"Puzzle 26\n",
"The Lion says: Unicorn told lies yesterday.\n",
"The Unicorn says: I told lies yesterday.\n",
"SOLUTION: Today is Sunday\n",
"--------------\n",
"\n",
"Puzzle 27\n",
"The Lion says: Unicorn told truths today.\n",
"The Unicorn says: Lion will tell lies tomorrow.\n",
"SOLUTION: Today is Sunday\n",
"--------------\n",
"\n",
"Puzzle 28\n",
"The Lion says: Unicorn told truths today.\n",
"The Unicorn says: Lion told truths today.\n",
"SOLUTION: Today is Sunday\n",
"--------------\n",
"\n",
"Puzzle 29\n",
"The Lion says: Unicorn told truths today.\n",
"The Unicorn says: Lion told truths yesterday.\n",
"SOLUTION: Today is Sunday\n",
"--------------\n",
"\n",
"Puzzle 30\n",
"The Lion says: Unicorn told truths today.\n",
"The Unicorn says: I told lies yesterday.\n",
"SOLUTION: Today is Sunday\n",
"--------------\n",
"\n",
"Puzzle 31\n",
"The Lion says: Unicorn told truths today.\n",
"The Unicorn says: I told truths today.\n",
"SOLUTION: Today is Sunday\n",
"--------------\n",
"\n",
"Puzzle 32\n",
"The Lion says: Unicorn told truths today.\n",
"The Unicorn says: I will tell truths tomorrow.\n",
"SOLUTION: Today is Sunday\n",
"--------------\n",
"\n",
"Puzzle 33\n",
"The Lion says: Unicorn will tell truths tomorrow.\n",
"The Unicorn says: Lion told truths today.\n",
"SOLUTION: Today is Sunday\n",
"--------------\n",
"\n",
"Puzzle 34\n",
"The Lion says: Unicorn will tell truths tomorrow.\n",
"The Unicorn says: Lion will tell truths tomorrow.\n",
"SOLUTION: Today is Wednesday\n",
"--------------\n",
"\n",
"Puzzle 35\n",
"The Lion says: Unicorn will tell truths tomorrow.\n",
"The Unicorn says: Lion told truths yesterday.\n",
"SOLUTION: Today is Sunday\n",
"--------------\n",
"\n",
"Puzzle 36\n",
"The Lion says: Unicorn will tell truths tomorrow.\n",
"The Unicorn says: I told lies yesterday.\n",
"SOLUTION: Today is Sunday\n",
"--------------\n",
"\n",
"Puzzle 37\n",
"The Lion says: Unicorn will tell truths tomorrow.\n",
"The Unicorn says: I will tell truths tomorrow.\n",
"SOLUTION: Today is Sunday\n",
"--------------\n",
"\n",
"Puzzle 38\n",
"The Lion says: Unicorn told truths yesterday.\n",
"The Unicorn says: Lion told lies today.\n",
"SOLUTION: Today is Thursday\n",
"--------------\n",
"\n",
"Puzzle 39\n",
"The Lion says: Unicorn told truths yesterday.\n",
"The Unicorn says: Lion will tell lies tomorrow.\n",
"SOLUTION: Today is Thursday\n",
"--------------\n",
"\n",
"Puzzle 40\n",
"The Lion says: Unicorn told truths yesterday.\n",
"The Unicorn says: Lion told truths yesterday.\n",
"SOLUTION: Today is Thursday\n",
"--------------\n",
"\n",
"Puzzle 41\n",
"The Lion says: Unicorn told truths yesterday.\n",
"The Unicorn says: I told lies yesterday.\n",
"SOLUTION: Today is Thursday\n",
"--------------\n",
"\n",
"Puzzle 42\n",
"The Lion says: Unicorn told truths yesterday.\n",
"The Unicorn says: I told truths today.\n",
"SOLUTION: Today is Thursday\n",
"--------------\n",
"\n",
"Puzzle 43\n",
"The Lion says: Unicorn told truths yesterday.\n",
"The Unicorn says: I will tell truths tomorrow.\n",
"SOLUTION: Today is Thursday\n",
"--------------\n",
"\n"
]
}
],
"source": [
"def describeIfValid(lionStatement, unicornStatement, counter):\n",
" #print(lionStatement)\n",
" lionPositive = intersect(lionStatement['days'], lionTruthful)\n",
" lionNegative = intersect(otherDays(lionStatement['days']), lionLying)\n",
" lionDays = union(lionPositive, lionNegative)\n",
" unicornPositive = intersect(unicornStatement['days'], unicornTruthful)\n",
" unicornNegative = intersect(otherDays(unicornStatement['days']),unicornLying)\n",
" unicornDays = union(unicornPositive, unicornNegative)\n",
" validDays = intersect(lionDays, unicornDays)\n",
" if (len(validDays) != 1):\n",
" return False\n",
" print(\"Puzzle \" + str(counter +1))\n",
" if ('Lion' in lionStatement['description']):\n",
" print(\"The Lion says: \" + lionStatement['description'].replace(\"Lion\", \"I\") + '.')\n",
" else:\n",
" print(\"The Lion says: \" + lionStatement['description'] + '.')\n",
" if ('Unicorn' in unicornStatement['description']):\n",
" print(\"The Unicorn says: \" + unicornStatement['description'].replace(\"Unicorn\", \"I\") + '.')\n",
" else:\n",
" print(\"The Unicorn says: \" + unicornStatement['description'] + '.')\n",
" print(\"SOLUTION: Today is \" + validDays[0])\n",
" print(\"--------------\")\n",
" print()\n",
" return True\n",
"\n",
"solutionCount = 0\n",
"for s1 in allAnnotated:\n",
" for s2 in allAnnotated:\n",
" if describeIfValid(s1,s2,solutionCount):\n",
" solutionCount = solutionCount + 1"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Even more puzzles"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can extend the number of puzzles by allowing the Lion and the Unicorn to talk about specific days, weekends, and weekdays."
]
},
{
"cell_type": "code",
"execution_count": 29,
"metadata": {},
"outputs": [],
"source": [
"def individualDays():\n",
" return [{'description': 'Today is ' + d, 'days':[d]} for d in daysOfWeek]\n",
"\n",
"def weekAndWeekend():\n",
" weekend = ['Saturday', 'Sunday']\n",
" return [{'description': 'Today is a weekday', 'days': otherDays(weekend)},\n",
" {'description': 'It is the weekend', 'days': weekend}]"
]
},
{
"cell_type": "code",
"execution_count": 30,
"metadata": {},
"outputs": [],
"source": [
"moreAnnotated = list(allAnnotated)\n",
"moreAnnotated.extend(individualDays())\n",
"moreAnnotated.extend(weekAndWeekend())"
]
},
{
"cell_type": "code",
"execution_count": 31,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[{'days': ['Monday', 'Tuesday', 'Wednesday'],\n",
" 'description': 'Lion told lies today'},\n",
" {'days': ['Sunday', 'Monday', 'Tuesday'],\n",
" 'description': 'Lion will tell lies tomorrow'},\n",
" {'days': ['Tuesday', 'Wednesday', 'Thursday'],\n",
" 'description': 'Lion told lies yesterday'},\n",
" {'days': ['Thursday', 'Friday', 'Saturday', 'Sunday'],\n",
" 'description': 'Lion told truths today'},\n",
" {'days': ['Wednesday', 'Thursday', 'Friday', 'Saturday'],\n",
" 'description': 'Lion will tell truths tomorrow'},\n",
" {'days': ['Friday', 'Saturday', 'Sunday', 'Monday'],\n",
" 'description': 'Lion told truths yesterday'},\n",
" {'days': ['Thursday', 'Friday', 'Saturday'],\n",
" 'description': 'Unicorn told lies today'},\n",
" {'days': ['Wednesday', 'Thursday', 'Friday'],\n",
" 'description': 'Unicorn will tell lies tomorrow'},\n",
" {'days': ['Friday', 'Saturday', 'Sunday'],\n",
" 'description': 'Unicorn told lies yesterday'},\n",
" {'days': ['Monday', 'Tuesday', 'Wednesday', 'Sunday'],\n",
" 'description': 'Unicorn told truths today'},\n",
" {'days': ['Sunday', 'Monday', 'Tuesday', 'Saturday'],\n",
" 'description': 'Unicorn will tell truths tomorrow'},\n",
" {'days': ['Tuesday', 'Wednesday', 'Thursday', 'Monday'],\n",
" 'description': 'Unicorn told truths yesterday'},\n",
" {'days': ['Monday'], 'description': 'Today is Monday'},\n",
" {'days': ['Tuesday'], 'description': 'Today is Tuesday'},\n",
" {'days': ['Wednesday'], 'description': 'Today is Wednesday'},\n",
" {'days': ['Thursday'], 'description': 'Today is Thursday'},\n",
" {'days': ['Friday'], 'description': 'Today is Friday'},\n",
" {'days': ['Saturday'], 'description': 'Today is Saturday'},\n",
" {'days': ['Sunday'], 'description': 'Today is Sunday'},\n",
" {'days': ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'],\n",
" 'description': 'Today is a weekday'},\n",
" {'days': ['Saturday', 'Sunday'], 'description': 'It is the weekend'}]"
]
},
"execution_count": 31,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"moreAnnotated"
]
},
{
"cell_type": "code",
"execution_count": 32,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Puzzle 1\n",
"The Lion says: I will tell lies tomorrow.\n",
"The Unicorn says: Lion told lies today.\n",
"SOLUTION: Today is Wednesday\n",
"--------------\n",
"\n",
"Puzzle 2\n",
"The Lion says: I will tell lies tomorrow.\n",
"The Unicorn says: Lion will tell lies tomorrow.\n",
"SOLUTION: Today is Sunday\n",
"--------------\n",
"\n",
"Puzzle 3\n",
"The Lion says: I will tell lies tomorrow.\n",
"The Unicorn says: Lion told lies yesterday.\n",
"SOLUTION: Today is Wednesday\n",
"--------------\n",
"\n",
"Puzzle 4\n",
"The Lion says: I will tell lies tomorrow.\n",
"The Unicorn says: Lion told truths today.\n",
"SOLUTION: Today is Sunday\n",
"--------------\n",
"\n",
"Puzzle 5\n",
"The Lion says: I will tell lies tomorrow.\n",
"The Unicorn says: Lion will tell truths tomorrow.\n",
"SOLUTION: Today is Wednesday\n",
"--------------\n",
"\n",
"Puzzle 6\n",
"The Lion says: I will tell lies tomorrow.\n",
"The Unicorn says: Lion told truths yesterday.\n",
"SOLUTION: Today is Sunday\n",
"--------------\n",
"\n",
"Puzzle 7\n",
"The Lion says: I will tell lies tomorrow.\n",
"The Unicorn says: I will tell lies tomorrow.\n",
"SOLUTION: Today is Wednesday\n",
"--------------\n",
"\n",
"Puzzle 8\n",
"The Lion says: I will tell lies tomorrow.\n",
"The Unicorn says: I told lies yesterday.\n",
"SOLUTION: Today is Sunday\n",
"--------------\n",
"\n",
"Puzzle 9\n",
"The Lion says: I will tell lies tomorrow.\n",
"The Unicorn says: I will tell truths tomorrow.\n",
"SOLUTION: Today is Sunday\n",
"--------------\n",
"\n",
"Puzzle 10\n",
"The Lion says: I will tell lies tomorrow.\n",
"The Unicorn says: I told truths yesterday.\n",
"SOLUTION: Today is Wednesday\n",
"--------------\n",
"\n",
"Puzzle 11\n",
"The Lion says: I will tell lies tomorrow.\n",
"The Unicorn says: Today is Wednesday.\n",
"SOLUTION: Today is Wednesday\n",
"--------------\n",
"\n",
"Puzzle 12\n",
"The Lion says: I will tell lies tomorrow.\n",
"The Unicorn says: Today is Sunday.\n",
"SOLUTION: Today is Sunday\n",
"--------------\n",
"\n",
"Puzzle 13\n",
"The Lion says: I will tell lies tomorrow.\n",
"The Unicorn says: Today is a weekday.\n",
"SOLUTION: Today is Wednesday\n",
"--------------\n",
"\n",
"Puzzle 14\n",
"The Lion says: I will tell lies tomorrow.\n",
"The Unicorn says: It is the weekend.\n",
"SOLUTION: Today is Sunday\n",
"--------------\n",
"\n",
"Puzzle 15\n",
"The Lion says: I told lies yesterday.\n",
"The Unicorn says: I told lies yesterday.\n",
"SOLUTION: Today is Thursday\n",
"--------------\n",
"\n",
"Puzzle 16\n",
"The Lion says: I told lies yesterday.\n",
"The Unicorn says: I told truths yesterday.\n",
"SOLUTION: Today is Monday\n",
"--------------\n",
"\n",
"Puzzle 17\n",
"The Lion says: I told lies yesterday.\n",
"The Unicorn says: Today is Tuesday.\n",
"SOLUTION: Today is Thursday\n",
"--------------\n",
"\n",
"Puzzle 18\n",
"The Lion says: I told lies yesterday.\n",
"The Unicorn says: Today is Wednesday.\n",
"SOLUTION: Today is Thursday\n",
"--------------\n",
"\n",
"Puzzle 19\n",
"The Lion says: I told lies yesterday.\n",
"The Unicorn says: Today is Friday.\n",
"SOLUTION: Today is Thursday\n",
"--------------\n",
"\n",
"Puzzle 20\n",
"The Lion says: I told lies yesterday.\n",
"The Unicorn says: Today is Saturday.\n",
"SOLUTION: Today is Thursday\n",
"--------------\n",
"\n",
"Puzzle 21\n",
"The Lion says: I told lies yesterday.\n",
"The Unicorn says: Today is Sunday.\n",
"SOLUTION: Today is Thursday\n",
"--------------\n",
"\n",
"Puzzle 22\n",
"The Lion says: I told lies yesterday.\n",
"The Unicorn says: Today is a weekday.\n",
"SOLUTION: Today is Monday\n",
"--------------\n",
"\n",
"Puzzle 23\n",
"The Lion says: I told lies yesterday.\n",
"The Unicorn says: It is the weekend.\n",
"SOLUTION: Today is Thursday\n",
"--------------\n",
"\n",
"Puzzle 24\n",
"The Lion says: I told truths today.\n",
"The Unicorn says: Lion told truths today.\n",
"SOLUTION: Today is Sunday\n",
"--------------\n",
"\n",
"Puzzle 25\n",
"The Lion says: I told truths today.\n",
"The Unicorn says: Lion will tell truths tomorrow.\n",
"SOLUTION: Today is Wednesday\n",
"--------------\n",
"\n",
"Puzzle 26\n",
"The Lion says: I will tell truths tomorrow.\n",
"The Unicorn says: I will tell lies tomorrow.\n",
"SOLUTION: Today is Saturday\n",
"--------------\n",
"\n",
"Puzzle 27\n",
"The Lion says: I will tell truths tomorrow.\n",
"The Unicorn says: I told lies yesterday.\n",
"SOLUTION: Today is Thursday\n",
"--------------\n",
"\n",
"Puzzle 28\n",
"The Lion says: I told truths yesterday.\n",
"The Unicorn says: Lion told truths today.\n",
"SOLUTION: Today is Sunday\n",
"--------------\n",
"\n",
"Puzzle 29\n",
"The Lion says: I told truths yesterday.\n",
"The Unicorn says: Lion will tell truths tomorrow.\n",
"SOLUTION: Today is Wednesday\n",
"--------------\n",
"\n",
"Puzzle 30\n",
"The Lion says: I told truths yesterday.\n",
"The Unicorn says: Lion told truths yesterday.\n",
"SOLUTION: Today is Sunday\n",
"--------------\n",
"\n",
"Puzzle 31\n",
"The Lion says: I told truths yesterday.\n",
"The Unicorn says: I told lies yesterday.\n",
"SOLUTION: Today is Sunday\n",
"--------------\n",
"\n",
"Puzzle 32\n",
"The Lion says: I told truths yesterday.\n",
"The Unicorn says: Today is Friday.\n",
"SOLUTION: Today is Saturday\n",
"--------------\n",
"\n",
"Puzzle 33\n",
"The Lion says: I told truths yesterday.\n",
"The Unicorn says: Today is Saturday.\n",
"SOLUTION: Today is Friday\n",
"--------------\n",
"\n",
"Puzzle 34\n",
"The Lion says: Unicorn told lies today.\n",
"The Unicorn says: Lion will tell truths tomorrow.\n",
"SOLUTION: Today is Wednesday\n",
"--------------\n",
"\n",
"Puzzle 35\n",
"The Lion says: Unicorn told lies today.\n",
"The Unicorn says: I told lies yesterday.\n",
"SOLUTION: Today is Thursday\n",
"--------------\n",
"\n",
"Puzzle 36\n",
"The Lion says: Unicorn will tell lies tomorrow.\n",
"The Unicorn says: I told lies yesterday.\n",
"SOLUTION: Today is Thursday\n",
"--------------\n",
"\n",
"Puzzle 37\n",
"The Lion says: Unicorn will tell lies tomorrow.\n",
"The Unicorn says: Today is Thursday.\n",
"SOLUTION: Today is Friday\n",
"--------------\n",
"\n",
"Puzzle 38\n",
"The Lion says: Unicorn will tell lies tomorrow.\n",
"The Unicorn says: Today is Friday.\n",
"SOLUTION: Today is Thursday\n",
"--------------\n",
"\n",
"Puzzle 39\n",
"The Lion says: Unicorn told lies yesterday.\n",
"The Unicorn says: Lion told truths today.\n",
"SOLUTION: Today is Sunday\n",
"--------------\n",
"\n",
"Puzzle 40\n",
"The Lion says: Unicorn told lies yesterday.\n",
"The Unicorn says: Lion will tell truths tomorrow.\n",
"SOLUTION: Today is Wednesday\n",
"--------------\n",
"\n",
"Puzzle 41\n",
"The Lion says: Unicorn told lies yesterday.\n",
"The Unicorn says: I told lies yesterday.\n",
"SOLUTION: Today is Sunday\n",
"--------------\n",
"\n",
"Puzzle 42\n",
"The Lion says: Unicorn told lies yesterday.\n",
"The Unicorn says: Today is Friday.\n",
"SOLUTION: Today is Saturday\n",
"--------------\n",
"\n",
"Puzzle 43\n",
"The Lion says: Unicorn told lies yesterday.\n",
"The Unicorn says: Today is Saturday.\n",
"SOLUTION: Today is Friday\n",
"--------------\n",
"\n",
"Puzzle 44\n",
"The Lion says: Unicorn told truths today.\n",
"The Unicorn says: Lion will tell lies tomorrow.\n",
"SOLUTION: Today is Sunday\n",
"--------------\n",
"\n",
"Puzzle 45\n",
"The Lion says: Unicorn told truths today.\n",
"The Unicorn says: Lion told truths today.\n",
"SOLUTION: Today is Sunday\n",
"--------------\n",
"\n",
"Puzzle 46\n",
"The Lion says: Unicorn told truths today.\n",
"The Unicorn says: Lion told truths yesterday.\n",
"SOLUTION: Today is Sunday\n",
"--------------\n",
"\n",
"Puzzle 47\n",
"The Lion says: Unicorn told truths today.\n",
"The Unicorn says: I told lies yesterday.\n",
"SOLUTION: Today is Sunday\n",
"--------------\n",
"\n",
"Puzzle 48\n",
"The Lion says: Unicorn told truths today.\n",
"The Unicorn says: I told truths today.\n",
"SOLUTION: Today is Sunday\n",
"--------------\n",
"\n",
"Puzzle 49\n",
"The Lion says: Unicorn told truths today.\n",
"The Unicorn says: I will tell truths tomorrow.\n",
"SOLUTION: Today is Sunday\n",
"--------------\n",
"\n",
"Puzzle 50\n",
"The Lion says: Unicorn told truths today.\n",
"The Unicorn says: Today is Sunday.\n",
"SOLUTION: Today is Sunday\n",
"--------------\n",
"\n",
"Puzzle 51\n",
"The Lion says: Unicorn told truths today.\n",
"The Unicorn says: It is the weekend.\n",
"SOLUTION: Today is Sunday\n",
"--------------\n",
"\n",
"Puzzle 52\n",
"The Lion says: Unicorn will tell truths tomorrow.\n",
"The Unicorn says: Lion told truths today.\n",
"SOLUTION: Today is Sunday\n",
"--------------\n",
"\n",
"Puzzle 53\n",
"The Lion says: Unicorn will tell truths tomorrow.\n",
"The Unicorn says: Lion will tell truths tomorrow.\n",
"SOLUTION: Today is Wednesday\n",
"--------------\n",
"\n",
"Puzzle 54\n",
"The Lion says: Unicorn will tell truths tomorrow.\n",
"The Unicorn says: Lion told truths yesterday.\n",
"SOLUTION: Today is Sunday\n",
"--------------\n",
"\n",
"Puzzle 55\n",
"The Lion says: Unicorn will tell truths tomorrow.\n",
"The Unicorn says: I told lies yesterday.\n",
"SOLUTION: Today is Sunday\n",
"--------------\n",
"\n",
"Puzzle 56\n",
"The Lion says: Unicorn will tell truths tomorrow.\n",
"The Unicorn says: I will tell truths tomorrow.\n",
"SOLUTION: Today is Sunday\n",
"--------------\n",
"\n",
"Puzzle 57\n",
"The Lion says: Unicorn will tell truths tomorrow.\n",
"The Unicorn says: Today is Monday.\n",
"SOLUTION: Today is Saturday\n",
"--------------\n",
"\n",
"Puzzle 58\n",
"The Lion says: Unicorn will tell truths tomorrow.\n",
"The Unicorn says: Today is Tuesday.\n",
"SOLUTION: Today is Saturday\n",
"--------------\n",
"\n",
"Puzzle 59\n",
"The Lion says: Unicorn will tell truths tomorrow.\n",
"The Unicorn says: Today is Thursday.\n",
"SOLUTION: Today is Saturday\n",
"--------------\n",
"\n",
"Puzzle 60\n",
"The Lion says: Unicorn will tell truths tomorrow.\n",
"The Unicorn says: Today is Friday.\n",
"SOLUTION: Today is Saturday\n",
"--------------\n",
"\n",
"Puzzle 61\n",
"The Lion says: Unicorn will tell truths tomorrow.\n",
"The Unicorn says: It is the weekend.\n",
"SOLUTION: Today is Sunday\n",
"--------------\n",
"\n",
"Puzzle 62\n",
"The Lion says: Unicorn told truths yesterday.\n",
"The Unicorn says: Lion told lies today.\n",
"SOLUTION: Today is Thursday\n",
"--------------\n",
"\n",
"Puzzle 63\n",
"The Lion says: Unicorn told truths yesterday.\n",
"The Unicorn says: Lion will tell lies tomorrow.\n",
"SOLUTION: Today is Thursday\n",
"--------------\n",
"\n",
"Puzzle 64\n",
"The Lion says: Unicorn told truths yesterday.\n",
"The Unicorn says: Lion told truths yesterday.\n",
"SOLUTION: Today is Thursday\n",
"--------------\n",
"\n",
"Puzzle 65\n",
"The Lion says: Unicorn told truths yesterday.\n",
"The Unicorn says: I told lies yesterday.\n",
"SOLUTION: Today is Thursday\n",
"--------------\n",
"\n",
"Puzzle 66\n",
"The Lion says: Unicorn told truths yesterday.\n",
"The Unicorn says: I told truths today.\n",
"SOLUTION: Today is Thursday\n",
"--------------\n",
"\n",
"Puzzle 67\n",
"The Lion says: Unicorn told truths yesterday.\n",
"The Unicorn says: I will tell truths tomorrow.\n",
"SOLUTION: Today is Thursday\n",
"--------------\n",
"\n",
"Puzzle 68\n",
"The Lion says: Unicorn told truths yesterday.\n",
"The Unicorn says: Today is Monday.\n",
"SOLUTION: Today is Thursday\n",
"--------------\n",
"\n",
"Puzzle 69\n",
"The Lion says: Unicorn told truths yesterday.\n",
"The Unicorn says: Today is Tuesday.\n",
"SOLUTION: Today is Thursday\n",
"--------------\n",
"\n",
"Puzzle 70\n",
"The Lion says: Unicorn told truths yesterday.\n",
"The Unicorn says: Today is Wednesday.\n",
"SOLUTION: Today is Thursday\n",
"--------------\n",
"\n",
"Puzzle 71\n",
"The Lion says: Unicorn told truths yesterday.\n",
"The Unicorn says: Today is Friday.\n",
"SOLUTION: Today is Thursday\n",
"--------------\n",
"\n",
"Puzzle 72\n",
"The Lion says: Unicorn told truths yesterday.\n",
"The Unicorn says: Today is Saturday.\n",
"SOLUTION: Today is Thursday\n",
"--------------\n",
"\n",
"Puzzle 73\n",
"The Lion says: Unicorn told truths yesterday.\n",
"The Unicorn says: Today is Sunday.\n",
"SOLUTION: Today is Thursday\n",
"--------------\n",
"\n",
"Puzzle 74\n",
"The Lion says: Unicorn told truths yesterday.\n",
"The Unicorn says: It is the weekend.\n",
"SOLUTION: Today is Thursday\n",
"--------------\n",
"\n",
"Puzzle 75\n",
"The Lion says: Today is Monday.\n",
"The Unicorn says: Lion will tell lies tomorrow.\n",
"SOLUTION: Today is Tuesday\n",
"--------------\n",
"\n",
"Puzzle 76\n",
"The Lion says: Today is Monday.\n",
"The Unicorn says: Lion will tell truths tomorrow.\n",
"SOLUTION: Today is Wednesday\n",
"--------------\n",
"\n",
"Puzzle 77\n",
"The Lion says: Today is Monday.\n",
"The Unicorn says: I will tell lies tomorrow.\n",
"SOLUTION: Today is Wednesday\n",
"--------------\n",
"\n",
"Puzzle 78\n",
"The Lion says: Today is Monday.\n",
"The Unicorn says: I will tell truths tomorrow.\n",
"SOLUTION: Today is Tuesday\n",
"--------------\n",
"\n",
"Puzzle 79\n",
"The Lion says: Today is Monday.\n",
"The Unicorn says: Today is Tuesday.\n",
"SOLUTION: Today is Tuesday\n",
"--------------\n",
"\n",
"Puzzle 80\n",
"The Lion says: Today is Monday.\n",
"The Unicorn says: Today is Wednesday.\n",
"SOLUTION: Today is Wednesday\n",
"--------------\n",
"\n",
"Puzzle 81\n",
"The Lion says: Today is Tuesday.\n",
"The Unicorn says: Lion will tell lies tomorrow.\n",
"SOLUTION: Today is Monday\n",
"--------------\n",
"\n",
"Puzzle 82\n",
"The Lion says: Today is Tuesday.\n",
"The Unicorn says: Lion told lies yesterday.\n",
"SOLUTION: Today is Wednesday\n",
"--------------\n",
"\n",
"Puzzle 83\n",
"The Lion says: Today is Tuesday.\n",
"The Unicorn says: Lion will tell truths tomorrow.\n",
"SOLUTION: Today is Wednesday\n",
"--------------\n",
"\n",
"Puzzle 84\n",
"The Lion says: Today is Tuesday.\n",
"The Unicorn says: Lion told truths yesterday.\n",
"SOLUTION: Today is Monday\n",
"--------------\n",
"\n",
"Puzzle 85\n",
"The Lion says: Today is Tuesday.\n",
"The Unicorn says: I will tell lies tomorrow.\n",
"SOLUTION: Today is Wednesday\n",
"--------------\n",
"\n",
"Puzzle 86\n",
"The Lion says: Today is Tuesday.\n",
"The Unicorn says: I will tell truths tomorrow.\n",
"SOLUTION: Today is Monday\n",
"--------------\n",
"\n",
"Puzzle 87\n",
"The Lion says: Today is Tuesday.\n",
"The Unicorn says: Today is Monday.\n",
"SOLUTION: Today is Monday\n",
"--------------\n",
"\n",
"Puzzle 88\n",
"The Lion says: Today is Tuesday.\n",
"The Unicorn says: Today is Wednesday.\n",
"SOLUTION: Today is Wednesday\n",
"--------------\n",
"\n",
"Puzzle 89\n",
"The Lion says: Today is Wednesday.\n",
"The Unicorn says: Lion told lies yesterday.\n",
"SOLUTION: Today is Tuesday\n",
"--------------\n",
"\n",
"Puzzle 90\n",
"The Lion says: Today is Wednesday.\n",
"The Unicorn says: Lion told truths yesterday.\n",
"SOLUTION: Today is Monday\n",
"--------------\n",
"\n",
"Puzzle 91\n",
"The Lion says: Today is Wednesday.\n",
"The Unicorn says: Today is Monday.\n",
"SOLUTION: Today is Monday\n",
"--------------\n",
"\n",
"Puzzle 92\n",
"The Lion says: Today is Wednesday.\n",
"The Unicorn says: Today is Tuesday.\n",
"SOLUTION: Today is Tuesday\n",
"--------------\n",
"\n",
"Puzzle 93\n",
"The Lion says: Today is Thursday.\n",
"The Unicorn says: Lion will tell truths tomorrow.\n",
"SOLUTION: Today is Wednesday\n",
"--------------\n",
"\n",
"Puzzle 94\n",
"The Lion says: Today is Thursday.\n",
"The Unicorn says: I will tell lies tomorrow.\n",
"SOLUTION: Today is Wednesday\n",
"--------------\n",
"\n",
"Puzzle 95\n",
"The Lion says: Today is Thursday.\n",
"The Unicorn says: I told lies yesterday.\n",
"SOLUTION: Today is Thursday\n",
"--------------\n",
"\n",
"Puzzle 96\n",
"The Lion says: Today is Thursday.\n",
"The Unicorn says: Today is Friday.\n",
"SOLUTION: Today is Thursday\n",
"--------------\n",
"\n",
"Puzzle 97\n",
"The Lion says: Today is Thursday.\n",
"The Unicorn says: Today is Saturday.\n",
"SOLUTION: Today is Thursday\n",
"--------------\n",
"\n",
"Puzzle 98\n",
"The Lion says: Today is Thursday.\n",
"The Unicorn says: Today is Sunday.\n",
"SOLUTION: Today is Thursday\n",
"--------------\n",
"\n",
"Puzzle 99\n",
"The Lion says: Today is Thursday.\n",
"The Unicorn says: It is the weekend.\n",
"SOLUTION: Today is Thursday\n",
"--------------\n",
"\n",
"Puzzle 100\n",
"The Lion says: Today is Friday.\n",
"The Unicorn says: Lion will tell truths tomorrow.\n",
"SOLUTION: Today is Wednesday\n",
"--------------\n",
"\n",
"Puzzle 101\n",
"The Lion says: Today is Friday.\n",
"The Unicorn says: Lion told truths yesterday.\n",
"SOLUTION: Today is Monday\n",
"--------------\n",
"\n",
"Puzzle 102\n",
"The Lion says: Today is Friday.\n",
"The Unicorn says: I will tell lies tomorrow.\n",
"SOLUTION: Today is Wednesday\n",
"--------------\n",
"\n",
"Puzzle 103\n",
"The Lion says: Today is Friday.\n",
"The Unicorn says: Today is Thursday.\n",
"SOLUTION: Today is Friday\n",
"--------------\n",
"\n",
"Puzzle 104\n",
"The Lion says: Today is Friday.\n",
"The Unicorn says: Today is Saturday.\n",
"SOLUTION: Today is Friday\n",
"--------------\n",
"\n",
"Puzzle 105\n",
"The Lion says: Today is Friday.\n",
"The Unicorn says: Today is Sunday.\n",
"SOLUTION: Today is Friday\n",
"--------------\n",
"\n",
"Puzzle 106\n",
"The Lion says: Today is Friday.\n",
"The Unicorn says: It is the weekend.\n",
"SOLUTION: Today is Friday\n",
"--------------\n",
"\n",
"Puzzle 107\n",
"The Lion says: Today is Saturday.\n",
"The Unicorn says: Lion will tell truths tomorrow.\n",
"SOLUTION: Today is Wednesday\n",
"--------------\n",
"\n",
"Puzzle 108\n",
"The Lion says: Today is Saturday.\n",
"The Unicorn says: Lion told truths yesterday.\n",
"SOLUTION: Today is Monday\n",
"--------------\n",
"\n",
"Puzzle 109\n",
"The Lion says: Today is Saturday.\n",
"The Unicorn says: Today is Thursday.\n",
"SOLUTION: Today is Saturday\n",
"--------------\n",
"\n",
"Puzzle 110\n",
"The Lion says: Today is Saturday.\n",
"The Unicorn says: Today is Friday.\n",
"SOLUTION: Today is Saturday\n",
"--------------\n",
"\n",
"Puzzle 111\n",
"The Lion says: Today is Saturday.\n",
"The Unicorn says: Today is Sunday.\n",
"SOLUTION: Today is Saturday\n",
"--------------\n",
"\n",
"Puzzle 112\n",
"The Lion says: Today is Sunday.\n",
"The Unicorn says: Lion told truths today.\n",
"SOLUTION: Today is Sunday\n",
"--------------\n",
"\n",
"Puzzle 113\n",
"The Lion says: Today is Sunday.\n",
"The Unicorn says: Lion will tell truths tomorrow.\n",
"SOLUTION: Today is Wednesday\n",
"--------------\n",
"\n",
"Puzzle 114\n",
"The Lion says: Today is Sunday.\n",
"The Unicorn says: I will tell lies tomorrow.\n",
"SOLUTION: Today is Wednesday\n",
"--------------\n",
"\n",
"Puzzle 115\n",
"The Lion says: Today is Sunday.\n",
"The Unicorn says: I told lies yesterday.\n",
"SOLUTION: Today is Sunday\n",
"--------------\n",
"\n",
"Puzzle 116\n",
"The Lion says: Today is Sunday.\n",
"The Unicorn says: Today is Monday.\n",
"SOLUTION: Today is Monday\n",
"--------------\n",
"\n",
"Puzzle 117\n",
"The Lion says: Today is Sunday.\n",
"The Unicorn says: Today is Tuesday.\n",
"SOLUTION: Today is Tuesday\n",
"--------------\n",
"\n",
"Puzzle 118\n",
"The Lion says: Today is Sunday.\n",
"The Unicorn says: Today is Wednesday.\n",
"SOLUTION: Today is Wednesday\n",
"--------------\n",
"\n",
"Puzzle 119\n",
"The Lion says: Today is Sunday.\n",
"The Unicorn says: Today is Sunday.\n",
"SOLUTION: Today is Sunday\n",
"--------------\n",
"\n",
"Puzzle 120\n",
"The Lion says: Today is Sunday.\n",
"The Unicorn says: It is the weekend.\n",
"SOLUTION: Today is Sunday\n",
"--------------\n",
"\n",
"Puzzle 121\n",
"The Lion says: Today is a weekday.\n",
"The Unicorn says: Lion told lies yesterday.\n",
"SOLUTION: Today is Friday\n",
"--------------\n",
"\n",
"Puzzle 122\n",
"The Lion says: Today is a weekday.\n",
"The Unicorn says: Lion told truths yesterday.\n",
"SOLUTION: Today is Thursday\n",
"--------------\n",
"\n",
"Puzzle 123\n",
"The Lion says: Today is a weekday.\n",
"The Unicorn says: I told lies yesterday.\n",
"SOLUTION: Today is Thursday\n",
"--------------\n",
"\n",
"Puzzle 124\n",
"The Lion says: Today is a weekday.\n",
"The Unicorn says: I told truths yesterday.\n",
"SOLUTION: Today is Friday\n",
"--------------\n",
"\n",
"Puzzle 125\n",
"The Lion says: Today is a weekday.\n",
"The Unicorn says: Today is Thursday.\n",
"SOLUTION: Today is Friday\n",
"--------------\n",
"\n",
"Puzzle 126\n",
"The Lion says: Today is a weekday.\n",
"The Unicorn says: Today is Friday.\n",
"SOLUTION: Today is Thursday\n",
"--------------\n",
"\n",
"Puzzle 127\n",
"The Lion says: It is the weekend.\n",
"The Unicorn says: Lion told truths today.\n",
"SOLUTION: Today is Sunday\n",
"--------------\n",
"\n",
"Puzzle 128\n",
"The Lion says: It is the weekend.\n",
"The Unicorn says: Lion will tell truths tomorrow.\n",
"SOLUTION: Today is Wednesday\n",
"--------------\n",
"\n",
"Puzzle 129\n",
"The Lion says: It is the weekend.\n",
"The Unicorn says: I told lies yesterday.\n",
"SOLUTION: Today is Sunday\n",
"--------------\n",
"\n",
"Puzzle 130\n",
"The Lion says: It is the weekend.\n",
"The Unicorn says: Today is Thursday.\n",
"SOLUTION: Today is Saturday\n",
"--------------\n",
"\n",
"Puzzle 131\n",
"The Lion says: It is the weekend.\n",
"The Unicorn says: Today is Friday.\n",
"SOLUTION: Today is Saturday\n",
"--------------\n",
"\n",
"Puzzle 132\n",
"The Lion says: It is the weekend.\n",
"The Unicorn says: It is the weekend.\n",
"SOLUTION: Today is Sunday\n",
"--------------\n",
"\n"
]
}
],
"source": [
"solutionCount = 0\n",
"for s1 in moreAnnotated:\n",
" for s2 in moreAnnotated:\n",
" if describeIfValid(s1,s2,solutionCount):\n",
" solutionCount = solutionCount + 1"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"With all these possible statements, we get to 132 puzzles."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.2"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment