Skip to content

Program can solve the famous Knight of Knave questions.

Notifications You must be signed in to change notification settings

KrishM123/Knight-or-Knave

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

Puzzle-Solver

Program can solve the famous Knight of Knave questions.

In 1978, logician Raymond Smullyan published “What is the name of this book?”, a book of logical puzzles. Among the puzzles in the book were a class of puzzles that Smullyan called “Knights and Knaves” puzzles.

In a Knights and Knaves puzzle, the following information is given: Each character is either a knight or a knave. A knight will always tell the truth: if knight states a sentence, then that sentence is true. Conversely, a knave will always lie: if a knave states a sentence, then that sentence is false.

The objective of the puzzle is, given a set of sentences spoken by each of the characters, determine, for each character, whether that character is a knight or a knave.

For example, consider a simple puzzle with just a single character named A. A says “I am both a knight and a knave.”

Logically, we might reason that if A were a knight, then that sentence would have to be true. But we know that the sentence cannot possibly be true, because A cannot be both a knight and a knave – we know that each character is either a knight or a knave, but not both. So, we could conclude, A must be a knave.

Usage: python puzzle.py

Harvard.CS50.Intro.To.AI.With.Python.Knights.Demonstration.mp4

About

Program can solve the famous Knight of Knave questions.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages