A dual-language repository where the same logic problems are solved in both C++ and Python — built to strengthen programming fundamentals and explore how different languages approach the same challenges.
This repo is part of my first-year CS journey. The idea is simple: take a programming concept, implement it in C++, then implement the same idea in Python — and see how each language handles it differently.
Each project lives in its own folder with two versions:
CPP_Version/— the original C++ implementationPython_Version/— the Python reimagining with improvements
📁 Logic-Craft-CPP-Python/
│
└── 📁 GenericConditionCounter/
├── 📁 CPP_Version/
│ └── 📄 GenericConditionCounter.cpp
└── 📁 Python_Version/
└── 📄 GenericConditionCounter.py
Count elements in a collection based on any condition — using function pointers in C++ and first-class functions in Python.
| C++ Version | Python Version | |
|---|---|---|
| Input | Random array (1–100 elements) | User fills list manually until "stop" |
| Logic | bool (*condition)(int) function pointer |
Lambda / function passed directly |
| Output | Count of even numbers | Even & odd lists printed separately |
| Extra | rand() + srand() for randomness |
Full input validation with error handling |
C++ — How to run:
g++ CPP_Version/GenericConditionCounter.cpp -o counter
./counterPython — How to run:
python Python_Version/GenericConditionCounter.py| Concept | C++ | Python |
|---|---|---|
| Arrays / Collections | Fixed-size arrays | Dynamic lists |
| Higher-order functions | Function pointers | First-class functions |
| Input validation | do-while loop |
try/except + loop |
| Random generation | rand() / srand() |
(user input instead) |
| Error handling | Basic range check | Catches non-integer input |
- How the same logic can be expressed differently across languages
- The power of higher-order functions (function pointers in C++, callables in Python)
- Writing clean, reusable functions instead of monolithic code
- Input validation and error handling in both languages
- Thinking in data structures: arrays vs. lists
- Add more problems (sorting, searching, string manipulation)
- Add
README.mdinside each project folder with deeper explanation - Use
std::vectorin C++ versions - Explore
std::mt19937for better randomness in C++ - Write unit tests for the Python versions
Mohammad Al-Sabbagh 🎓 First-Year CS Student — Al-Balqa Applied University, Ajloun College
Every problem solved in two languages is twice the understanding. Still learning, always building. 💪