Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

CS50 - Introduction to AI with Python

Knights and Knaves puzzle

The Knights and Knaves puzzle is a logic game where characters are either Knights, who always tell the truth, or Knaves, who always lie. The goal is to determine the identity of each character based on their statements.

This implementation solves the following puzzles:

  • Puzzle 0 contains a single character, A.

    • A says “I am both a knight and a knave.”
  • Puzzle 1 has two characters: A and B.

    • A says “We are both knaves.”
    • B says nothing.
  • Puzzle 2 has two characters: A and B.

    • A says “We are the same kind.”
    • B says “We are of different kinds.”
  • Puzzle 3 has three characters: A, B, and C.

    • A says either “I am a knight.” or “I am a knave.”, but you don’t know which.
    • B says “A said ‘I am a knave.’”
    • B then says “C is a knave.”
    • C says “A is a knight.”

Running the project

  1. Clone this repo.
  2. Run the file:
python3 puzzle.py
  1. You'll get the answers in the terminal window.

Note

This project is part of the CS50 - Introduction to AI with Python course.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages