exercises and solutions

Difficulty labels

Difficulty describes the decisions an exercise requires, not its line count. A short authentication or transaction task can be advanced because the consequences are subtle.

  • Beginner: practise one taught concept with clear input and expected output.
  • Intermediate: combine familiar concepts and make a small design decision.
  • Advanced: cross boundaries or reason about security, persistence, concurrency, or operations.

Practical Example

PHP example
<?php

declare(strict_types=1);

$minutes = 25;

$difficulty = match (true) {
    $minutes <= 15 => 'beginner',
    $minutes <= 45 => 'intermediate',
    default => 'advanced',
};

echo $difficulty . PHP_EOL;

// Prints:
// intermediate

Time can help estimate workload, but it does not determine difficulty. Labels set expectations; prerequisites and requirements still need to be explicit.

Practice

Label Three Exercises
  1. Multiply a price by a quantity and print the total.
  2. Validate a form field, preserve errors, and escape the redisplayed value.
  3. Design idempotent webhook handling with a database transaction.