A terminal-based trivia game written in Python where players guess the lie hidden among three statements. Built with custom data structures and a CSV data pipeline for managing and validating question sets.
Each round presents three statements — two are true, one is a lie. Your job is to pick the lie. Choose a category, answer up to 5 questions, and see how well you score.
┌─────────────────────────────────────────┐
│ Two Truths and a Lie │
├─────────────────────────────────────────┤
│ 1) Play Game │
│ 2) Exit │
└─────────────────────────────────────────┘
- Python 3.7+
- No external dependencies — uses only the standard library
# 1. Clone the repository
git clone https://github.com/gonzaherman99/TwoTruths-OneLie.git
cd TwoTruths-OneLie
# 2. Run the game
python "project python.py"That's it. No pip installs needed.
TwoTruths-OneLie/
├── project python.py # Main game entry point and UI
├── optimized_csv.py # CSV data pipeline and optimizer
├── lies.csv # Question dataset (Truth1, Truth2, Lie, Category)
├── optimized_data.jsonl # Processed question data (auto-generated)
├── data_index.json # Fast-lookup index by entry ID (auto-generated)
├── data.zip # Compressed JSONL archive (auto-generated)
└── validation_report.json # Data quality report (auto-generated)
The game uses two custom data structures implemented from scratch:
HashTable — Organizes questions by category for O(1) average-case lookup. Questions are bucketed by topic so the game can quickly retrieve all entries for a chosen category.
StatementTree (Binary Search Tree) — Indexes every individual statement for duplicate detection and fast search across the full question pool.
The CSVOptimizer class handles loading and processing the raw lies.csv file before the game starts:
- Column detection — Automatically finds truth/lie columns by name (no hardcoded headers needed)
- Duplicate removal — Hashes each statement set with SHA-256 to deduplicate entries
- Validation — Skips malformed rows and logs invalid entry counts
- Storage optimization — Exports to
.jsonl, compresses to.zip, and builds a JSON index for fast access
The pipeline can run standalone to regenerate the processed files:
python optimized_csv.pyThe game reads from lies.csv. The file must have columns with "truth" and "lie" in their names, and optionally a Category column:
| Truth1 | Truth2 | Lie | Category |
|---|---|---|---|
| Water boils at 100°C | The sky is blue | Cats can fly | Science |
| Paris is in France | Gold is a metal | Fish can climb trees | General |
Column names are detected automatically — as long as they contain the words truth and lie, the optimizer will find them.
If you update lies.csv and want to regenerate the processed files:
python optimized_csv.pyThis will output:
optimized_data.jsonl— one JSON entry per questiondata.zip— compressed version of the abovedata_index.json— ID-based lookup indexvalidation_report.json— summary of processed, duplicate, and invalid entries
Pull requests are welcome! If you'd like to add questions, fix bugs, or improve the UI, feel free to fork the repo and open a PR.
- Fork the project
- Create a feature branch (
git checkout -b feature/my-feature) - Commit your changes (
git commit -m 'Add my feature') - Push to the branch (
git push origin feature/my-feature) - Open a Pull Request
This project is open source. Feel free to use, modify, and distribute it.