{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "08c395c5",
   "metadata": {},
   "source": [
    "# 19-14 · Czas, prędkość i opóźnienia\n",
    "\n",
    "Praktyka do sekcji [„Czas, prędkość i opóźnienia”"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "633ed20f",
   "metadata": {},
   "source": [
    "## Cel\n",
    "\n",
    "calculate_delay() zmniejsza opóźnienia liczenia, nie schodząc poniżej minimum."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e87e1f23",
   "metadata": {},
   "source": [
    "## Sprawa robocza"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "1ad0b62f",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-09-03T00:53:50.391118Z",
     "iopub.status.busy": "2026-09-03T00:53:50.390966Z",
     "iopub.status.idle": "2026-09-03T00:53:50.414858Z",
     "shell.execute_reply": "2026-09-03T00:53:50.414357Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "140 130 120\n"
     ]
    }
   ],
   "source": [
    "def calculate_delay(score, *, base_ms=140, min_ms=60, step_score=50, step_ms=10):\n",
    "    steps = score // step_score\n",
    "    return max(min_ms, base_ms - steps * step_ms)\n",
    "\n",
    "print(calculate_delay(0), calculate_delay(50), calculate_delay(100))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "35e89811",
   "metadata": {},
   "source": [
    "## Podstawowa praktyka zadań ★"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "37014f6c",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-09-03T00:53:50.416315Z",
     "iopub.status.busy": "2026-09-03T00:53:50.416164Z",
     "iopub.status.idle": "2026-09-03T00:53:50.419269Z",
     "shell.execute_reply": "2026-09-03T00:53:50.418322Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Скорость растёт со счётом и не опускается ниже минимума.\n"
     ]
    }
   ],
   "source": [
    "assert calculate_delay(0) == 140\n",
    "assert calculate_delay(50) == 130\n",
    "assert calculate_delay(100_000) == 60\n",
    "print(\"Скорость растёт со счётом и не опускается ниже минимума.\")"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Cartesian Python 3.14",
   "language": "python",
   "name": "cartesian-python314"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.14.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
