Programming Exercises
Practice with real problems and instant feedback.
Python Collections Counter
Use Python collections.Counter for efficient frequency counting, most common elements, and arithmetic operations.
Custom Context Manager
Implement a custom context manager using __enter__ and __exit__ for resource management.
Python Coroutine Pipeline
Build a data processing pipeline using Python coroutines with send() for streaming data transformation.
Dataclass with Validation
Use Python dataclasses with __post_init__ for automatic field validation and default factories.
Python Datetime Arithmetic
Use Python datetime module to perform date arithmetic, calculate differences, and handle timezone-aware operations.
Decorator with LRU Cache
Combine custom decorators with functools.lru_cache for memoized function calls.
Python Decorator Pattern
Implement a Python decorator that measures and logs function execution time using functools.wraps for metadata preservation.
Python Descriptor Protocol
Implement a Python descriptor using __get__ and __set__ to create a validated attribute that enforces type constraints.
Dictionary Merge and Update
Merge dictionaries using Python 3.9+ merge operator and update method with conflict resolution.
Python Dictionary Operations
Perform common dictionary operations including merging, filtering, and transforming values in Python.
Python LCS Dynamic Programming
Implement the longest common subsequence algorithm using dynamic programming with a 2D table.
Python Exception Handling
Use Python try-except-else-finally blocks to handle different exception types and ensure cleanup code runs.
Python File Reading
Read a text file line by line in Python, processing each line and handling file not found errors gracefully.
Python Default Arguments
Use Python default parameter values and keyword arguments to create flexible and configurable functions.
Python Generator Functions
Use Python generator functions with yield to create memory-efficient lazy sequences for large data processing.
Generator Functions with Yield
Create generator functions using yield for memory-efficient lazy evaluation of large sequences.
Python Dijkstra Shortest Path
Implement Dijkstra algorithm for finding shortest paths in a weighted graph using a priority queue.
Python Itertools Chains
Use Python itertools module to chain, slice, and group iterables for efficient lazy data processing.
List Comprehension Patterns
Use Python list comprehensions with conditions and nested loops for concise data transformation.
Python Loop Patterns
Use Python enumerate, zip, and range patterns for common iteration tasks with proper unpacking.
Memoized Fibonacci
Implement memoized Fibonacci using functools.lru_cache for O(n) time complexity instead of exponential.
Python Metaclass Basics
Implement a custom metaclass that automatically adds validation methods to classes based on their field definitions.
Python NamedTuple Usage
Use Python namedtuple for creating lightweight immutable record types with named field access.
Python Recursive Descent Parser
Implement a recursive descent parser for simple arithmetic expressions with operator precedence and parentheses.
Regex Named Groups
Use Python regex named groups for extracting structured data from text patterns.
Python Regex Substitution
Use Python re module for pattern matching and substitution with capture groups and replacement functions.
Python Set Operations
Use Python set operations (union, intersection, difference) to compare and manipulate collections of unique elements.
Python Sorted with Key Function
Use Python sorted() with custom key functions for multi-criteria sorting and complex comparison logic.
SQL Parameterized Queries
Use parameterized queries with sqlite3 to prevent SQL injection and safely pass user input.
Python String Formatting
Use Python f-strings and format methods to create formatted output with variables, alignment, and number precision.
Python String Methods
Use Python string methods (split, join, strip, replace, find) for common text processing tasks.
Python Tuple Unpacking
Use Python tuple unpacking and the star expression to extract values from tuples of varying structures.
TypedDict for Structured Dicts
Use TypedDict to create type-checked dictionary structures with mypy static analysis.
Rust Async/Await
Use Rust async/await with tokio runtime for concurrent asynchronous operations and task spawning.
Closures and Capture
Use Rust closures with move semantics and Fn, FnMut, FnOnce traits for captured variables.
Rust Closures and Capture
Use Rust closures with different capture modes (by reference, by mutable reference, by value) and the move keyword.
HashMap Operations
Use Rust HashMap for key-value storage with insertion, lookup, and iteration patterns.
Thread Spawning with Channels
Use std::thread and mpsc channels for safe message passing between Rust threads.
Result Type Error Handling
Use Rust Result type for explicit error handling without exceptions using match and ? operator.
Rust Generic Traits
Define and implement generic traits in Rust with associated types and generic methods.
Rust Iterator Adapters
Chain Rust iterator adapters like map, filter, enumerate, and collect for functional data transformation.
Iterator Map and Filter
Use Rust iterator adaptors map, filter, and collect for functional data transformation.
Rust Lifetime Annotations
Use Rust lifetime annotations to express relationships between references in function signatures.
Explicit Lifetime Annotations
Use explicit lifetime annotations to tell the borrow checker about reference relationships.
Rust Declarative Macros
Write Rust declarative macros with macro_rules! for code generation and pattern-based syntax extension.
Ownership and Move Semantics
Demonstrate Rust ownership rules with move semantics and borrowing to prevent data races.
Rust Ownership Transfer
Learn Rust ownership rules by transferring ownership between functions and using references to borrow values.
Pattern Matching with Enums
Use Rust pattern matching on enums with exhaustive match arms and guard clauses.
Rust Pattern Matching
Use Rust match expressions with destructuring, guards, and binding for comprehensive pattern matching.
Smart Pointers Box and Rc
Use Box for heap allocation and Rc for reference counting in Rust programs.
Rust String Slices
Use Rust string slices (&str) for efficient substring access without copying string data.
Rust Struct Basics
Define Rust structs with fields, implement methods, and use derive macros for common traits.
Rust Trait Bounds
Use Rust trait bounds on generic functions to constrain type parameters to types implementing specific traits.
Traits with Generic Bounds
Define and implement traits with generic type bounds for polymorphic behavior in Rust.
Rust Unsafe and FFI
Use Rust unsafe blocks for raw pointer dereferencing and FFI to call C functions safely.
Rust Vector Iteration
Iterate over Rust vectors using various patterns: by value, by reference, and with iterator adaptors.
SQL CASE Expressions
Use SQL CASE expressions for conditional logic and value transformation within queries.
Recursive CTE for Hierarchy
Use recursive common table expressions to traverse hierarchical data like org charts.
SQL Common Table Expressions
Use SQL CTEs (WITH clause) for readable query decomposition and reusable intermediate result sets.
Date Truncation for Grouping
Use date_trunc and extract functions to group time series data by various time periods.
EXISTS vs IN Subqueries
Compare EXISTS and IN subquery performance and use appropriate pattern for each case.
SQL GROUP BY with Aggregates
Use SQL GROUP BY with aggregate functions like COUNT, SUM, AVG, MIN, and MAX for data summarization.
SQL HAVING Clause
Use SQL HAVING clause to filter groups after aggregation, complementing WHERE for pre-aggregation filtering.
SQL INSERT and UPDATE
Use SQL INSERT to add rows and UPDATE to modify existing rows with WHERE conditions.
Join with Aggregation
Combine table joins with GROUP BY aggregation for reporting queries with multiple tables.
SQL INNER JOIN
Use SQL INNER JOIN to combine rows from two tables based on a related column between them.
JSON Data Querying
Query and extract data from JSON columns using PostgreSQL JSON operators and functions.
NULL Handling with COALESCE
Use COALESCE, NULLIF, and IS NULL for robust NULL value handling in SQL queries.
SQL ORDER BY and LIMIT
Use SQL ORDER BY for sorting and LIMIT/OFFSET for pagination to control result set size and order.
Pivot Data with CASE
Transform rows to columns using CASE expressions for pivot-style data reshaping in SQL.
SQL Recursive CTE
Use SQL recursive CTEs to traverse hierarchical data like org charts, trees, and graph structures.
SQL SELECT with WHERE
Write SQL SELECT queries with WHERE clauses to filter rows by various conditions and comparison operators.
SQL Subqueries
Use SQL subqueries in WHERE, FROM, and SELECT clauses for nested data retrieval and filtering.
SQL UNION and UNION ALL
Use SQL UNION and UNION ALL to combine result sets from multiple queries into a single result.
UPSERT with ON CONFLICT
Use INSERT ON CONFLICT for atomic upsert operations in PostgreSQL with comprehensive examples and best practices for production use.
SQL Window Functions
Use SQL window functions like ROW_NUMBER, RANK, and LAG for analytics without collapsing rows.
Window Function Ranking
Use SQL window functions with RANK, DENSE_RANK, and ROW_NUMBER for analytical queries.
Running Total with Window
Calculate running totals and moving averages using SQL window functions with frame clauses.
Typed Array Map Operation
Use the Array.map method with proper TypeScript generics to transform an array of numbers into an array of strings.
Async/Await Error Handling
Write an async function with proper TypeScript error handling using try-catch and typed error responses.
Async Iterable Class
Implement an async iterable class using Symbol.asyncIterator for streaming data processing.
TypeScript Basic Type Annotations
Practice declaring variables with explicit TypeScript type annotations for numbers, strings, and booleans.
Branded Types for Nominal Typing
Implement branded types to achieve nominal typing in TypeScript structural type system for safer domain types.
Type-Safe Builder Pattern
Implement a type-safe builder pattern using method chaining with TypeScript return types.
Conditional Types
Use conditional types to create type-level logic that selects types based on conditions.
Generic Curried Function Types
Create a fully typed curry function with TypeScript generics that preserves parameter types through partial application.
Method Decorator Logging
Implement a method decorator that logs function calls with arguments and return values for debugging purposes.
Method Decorators
Implement method decorators for logging, timing, and access control in TypeScript classes.
Discriminated Union Patterns
Use discriminated unions to model different action types with exhaustive switch handling in a reducer pattern.
Distributive Conditional Types
Explore distributive conditional types that distribute over union types for type-level computations.
Enum Iteration and Reverse Mapping
Iterate over TypeScript enum values and handle reverse mapping for numeric enums.
Enum Type Usage
Define and use a TypeScript enum to represent order status values with a function to check if an order is complete.
Function Overload Signatures
Use TypeScript function overload signatures to provide different return types based on input parameter types.
Generic Stack Class
Implement a type-safe generic stack class in TypeScript with push, pop, and peek methods.
Generic Type Inference
Write a generic identity function and a generic pair factory, demonstrating TypeScript automatic type inference.
Type Inference in Conditional Types
Use the infer keyword in conditional types to extract and manipulate types from complex generic structures.
Interface Definition Basics
Define a TypeScript interface for a User object with required and optional properties, then create a function to display user info.
Iterator Protocol Implementation
Implement a custom iterator using the Symbol.iterator protocol for a range class that yields numbers.
Mapped Types
Create mapped types that transform existing type properties into new type structures.
Phantom Types for Safety
Use phantom types to create type-level tags that distinguish values at compile time without runtime overhead.