/selfreferential-logical-puzzles

either solve or create a type of logical puzzle made up by a list of questions referring only to their own list of answers

Primary LanguagePythonGNU General Public License v3.0GPL-3.0

Selfreferential logical puzzles

PROJECT DESCRIPTION:

Functionalities for logical puzzles made up of collectively self-referential questions (as in the below example):

  • Logical representation
  • Brute-force solution
  • Automated search for a puzzle having the desired characteristics: types and nr. of questions, nr. of possible answers for each question, nr. of solutions (without validating beforehand whether it is feasible to create a puzzle with the chosen set of characteristics)

Developed in Python 3.9.1.

ACKNOWLEDGEMENTS:

Many thanks to my colleague Heidi Pang, because during our free time, she inspired this project by posing the sample puzzle, co-authored with me an earlier version of this code in pair programming and, last but not least, managed to teach me something I did not know about Python. It is great to have colleagues like her, always pushing me to improve!

PUZZLE EXAMPLE, WITH SOLUTION:

LOGICAL PUZZLE MADE UP BY COLLECTIVELY SELF-REFERENTIAL QUESTIONS

  1. The first question with B as the correct answer is:

A. 1     B. 4     C. 3     D. 2

  1. The answer to Question 4 is:

A. D     B. A     C. B     D. C

  1. The answer to Question 1 is:

A. D     B. C     C. A     D. B

  1. The number of questions which have D as the correct answer is:

A. 3     B. 2     C. 1     D. 0

  1. The number of questions which have B as the correct answer is:

A. 0     B. 2     C. 3     D. 1

SOLUTION(S)

--- List of all possible sequences of answers: ---

1. C,    2. D,    3. B,    4. C,    5. B

--- End of the list ---

This puzzle has exactly 1 solution.