Skip to content

Hazzaa-Nassar/microcode-dojo

Repository files navigation

Microcodedojo

A lightweight, terminal-based coding practice platform for Python.
Microcodedojo gives you a fast loop for deliberate practice:

  1. pick an exercise, 2. code your solution in work/, 3. run tests, 4. track progress.

Features

  • 73 exercises across 3 difficulty levels (exercises/*.py)
  • 🧪 Comprehensive test suites for every exercise (tests/test_*.py)
  • 📁 Reference solutions to learn from (solutions/*.py)
  • 📊 Progress tracking with automatic scoring (~/.microcodedojo/progress.json)
  • 💾 Timestamped backups to protect your work (~/.microcodedojo/backups/)
  • 🎯 10 points per solved exercise → 730 points total

Quick Start

Installation

# Clone or download the project
cd microcodedojo

# Setup (WSL/Ubuntu)
bash setup.sh

# List all available exercises
python3 run.py list

Core Workflow

# 1. Create/open your work file
python3 run.py run two_numbers

# 2. Edit work/two_numbers.py in your editor

# 3. Run tests for that exercise
python3 run.py test two_numbers

# 4. Check your progress
python3 run.py stats

Commands

Command Description Example
list List all available exercise ids python3 run.py list
run <id> Create/open work/<id>.py from template python3 run.py run prime_check
test <id> Run unittest and update progress python3 run.py test prime_check
solution <id> Print path to reference solution python3 run.py solution prime_check
stats Show score, solved count, attempts python3 run.py stats
backup Create timestamped backup python3 run.py backup

Exercise Overview

🟢 Beginner (23 exercises)
Basic I/O, arithmetic, simple logic
Examples: two_numbers, sum_range, max_of_three, temperature_convert

🟡 Intermediate (25 exercises)
Strings, lists, data manipulation
Examples: count_vowels, reverse_words, dedupe_keep_order, merge_sorted_lists

🔴 Advanced (25 exercises)
Algorithms, complex logic, problem-solving
Examples: prime_check, fibonacci_n, bracket_balance, two_sum_indices

Example: First Exercise

$ python3 run.py run two_numbers
✅ Ready: work/two_numbers.py
Edit this file, then run:
  python3 run.py test two_numbers

Edit work/two_numbers.py:

def solve() -> str:
    a, b = map(int, input().split())
    return str(a + b)

if __name__ == "__main__":
    print(solve())

Test it:

$ python3 run.py test two_numbers
..
OK
✅ PASS

$ python3 run.py stats
Score: 10
Solved: 1
Attempts: 1

Progress Tracking

Progress is stored in: ~/.microcodedojo/progress.json

Example structure:

{
  "version": 1,
  "score": 150,
  "exercises": {
    "two_numbers": {
      "solved": true,
      "attempts": 1,
      "solved_at": "2026-02-15T14:30:00+00:00"
    }
  }
}

Backup System

Create a backup:

$ python3 run.py backup
✅ Backup created: ~/.microcodedojo/backups/backup_20260215_143022
Backed up 5 item(s):
  - progress.json
  - work/two_numbers.py
  - work/string_info.py

Backups are stored in: ~/.microcodedojo/backups/backup_YYYYMMDD_HHMMSS/

To restore:

# Restore progress
cp ~/.microcodedojo/backups/backup_20260215_143022/progress.json ~/.microcodedojo/

# Restore work files
cp ~/.microcodedojo/backups/backup_20260215_143022/work/*.py work/

Project Structure

microcodedojo/
├── run.py              # Main CLI tool
├── setup.sh            # Setup script
├── README.md           # This file
├── exercises/          # Exercise templates (incomplete)
├── solutions/          # Reference solutions (complete)
├── tests/              # Test suites
└── work/               # Your solutions (created on demand)

~/.microcodedojo/       # User data (hidden directory)
├── progress.json       # Your progress
└── backups/            # Timestamped backups

Troubleshooting

Issue: "ModuleNotFoundError: No module named 'tests'"
Solution: Make sure you're in the project root directory

Issue: "Unknown exercise"
Solution: Run python3 run.py list to see available exercises

Issue: Corrupted progress.json
Solution: Run python3 run.py stats - it will auto-repair

Issue: Tests fail but code works manually
Solution: Check for extra whitespace or incorrect output format

Development

Running All Tests

# Test specific exercise
python3 -m unittest tests.test_two_numbers

# Test all exercises (from project root)
python3 -m unittest discover tests

# Verify all reference solutions work
bash test_all_solutions.sh

Adding New Exercises

  1. Create template in exercises/<name>.py
  2. Create solution in solutions/<name>.py
  3. Create test in tests/test_<name>.py
  4. Test with: python3 run.py test <name>

Requirements

  • Python 3.8+
  • Unix-like environment (Linux, WSL, macOS)
  • Terminal/command line access

License

Educational use — free to use and modify for learning purposes.


Quick Reference

# Setup
bash setup.sh

# Practice
python3 run.py list                    # Show exercises
python3 run.py run <exercise>          # Start exercise
python3 run.py test <exercise>         # Test solution

# Progress
python3 run.py stats                   # View progress
python3 run.py solution <exercise>     # See reference

# Safety
python3 run.py backup                  # Backup your work

Ready to start? Run python3 run.py list and pick your first exercise! 🚀

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors