This project addresses a logical puzzle involving gnomes in a fairyland who can see each other's hat colors but not their own. Observations (evidences) about hat colors are analyzed to deduce consistent conclusions or identify contradictions. The challenge spans four interconnected questions, each building on the previous.
- Hat Colors: Encoded as
1(white) and0(black). - Evidence: A list of tuples containing:
- A pair of gnome IDs.
- The number of white hats observed on them (
0,1,2).
- Contradiction Detection: Identify whether evidences are consistent or contain contradictions.
- Graph Representation: Model gnome pairs with differing hat colors as a graph.
- Reasoning with Graphs: Traverse the graph to deduce hat colors using depth-first search (DFS).
- Python
- Kerui Huang
- University of Melbourne COMP10001 Teaching Team (Question Provider)
This project is for academic purposes under the University of Melbourne's COMP10001 course.
Clone the repository and run the Python scripts for each question:
git clone https://github.com/MoltoRubato/FOC_Project2.git
cd FOC_Project2
python3 P2Q1.py
python3 P2Q2.py
python3 P2Q3.py
python3 P2Q4.py