Skip to content

ibrahim317/c-challanges

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

C Challenges

A collection of C programming challenges designed to help you master C concepts. Each challenge focuses on real-world programming skills including memory management, data structures, concurrency, and system programming.

🎯 Difficulty Levels

  • Warm-up: Introduction to challenge structure
  • Easy: Basic pointers, arrays, strings, and simple structs
  • Medium: Dynamic memory, data structures, function pointers
  • Hard: Concurrency, custom memory management, generic programming
  • Extreme: Lock-free data structures, advanced system programming

πŸš€ Quick Start

Prerequisites

  • GCC compiler
  • CMake (version 3.10 or higher)
  • CMocka testing framework

Installation

  1. Clone this repository:
git clone https://github.com/your-username/advanced-c-challenges.git
cd advanced-c-challenges
  1. Install dependencies:
# Ubuntu/Debian
sudo apt-get install cmocka-dev cmake

# macOS
brew install cmocka cmake

# Or build CMocka from source
git clone https://gitlab.com/cmocka/cmocka.git
cd cmocka && mkdir build && cd build
cmake .. && make && sudo make install
  1. Run all tests:
make test

Working on Challenges

  1. Navigate to any challenge directory:
cd challenges/easy/001-array-sum
  1. Read the challenge description:
cat README.md
  1. Implement the functions in a new file (e.g., solution.c):
#include "challenge.h"

int array_sum(int* arr, size_t size) {
    // Your implementation here
    return 0;
}
  1. Build and test:
make test

πŸ“ Project Structure

advanced_c/
β”œβ”€β”€ challenges/
β”‚   β”œβ”€β”€ warm-up/           # 1 challenge
β”‚   β”œβ”€β”€ easy/             # 5 challenges
β”‚   β”œβ”€β”€ medium/           # 5 challenges
β”‚   β”œβ”€β”€ hard/             # 4 challenges
β”‚   └── extreme/          # 3 challenges
β”œβ”€β”€ scripts/              # Utility scripts
β”œβ”€β”€ Makefile              # Root build system
└── README.md             # This file

πŸ§ͺ Testing

Each challenge includes comprehensive CMocka tests that verify:

  • Correct functionality
  • Memory safety
  • Edge cases
  • Error handling

Run tests with:

make test              # All challenges
make test-easy         # Easy challenges only
make test-medium       # Medium challenges only
make test-hard         # Hard challenges only
make test-extreme      # Extreme challenges only

πŸ“š Challenge Topics

Easy

  • Pointer arithmetic and dereferencing
  • Array manipulation
  • String operations
  • Basic memory allocation
  • Simple data structures

Medium

  • Dynamic memory management
  • Complex data structures (trees, hash tables)
  • Function pointers and callbacks
  • Memory pools
  • Generic programming basics

Hard

  • Thread-safe programming
  • Custom memory allocators
  • Generic containers
  • Signal handling
  • System programming

Extreme

  • Lock-free data structures
  • Memory debugging tools
  • Coroutines and fibers
  • Compiler features
  • Low-level optimization

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/new-challenge
  3. Add your challenge following the existing structure
  4. Ensure all tests pass: make test
  5. Submit a pull request

Adding New Challenges

  1. Create a new directory in the appropriate difficulty folder
  2. Add README.md with challenge description
  3. Create challenge.h with function signatures
  4. Write test_challenge.c with CMocka tests
  5. Add a Makefile for the challenge
  6. Update the root Makefile to include your challenge

πŸ“– Resources

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

⭐ Star History

Star History Chart


About

A collection of C programming challenges designed to help you master C concepts

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published