{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "3cf1a819",
   "metadata": {},
   "source": [
    "# 17-26 · Wyniki meczów\n",
    "\n",
    "Praktyka do sekcji [„Wyniki meczów”"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c6fd0cc2",
   "metadata": {},
   "source": [
    "## Cel\n",
    "\n",
    "Aktualizuj wynik meczu za pomocą czystej funkcji – raz na mecz."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f0bc7b39",
   "metadata": {},
   "source": [
    "## Sprawa robocza"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "b3b0689d",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-09-03T10:13:20.654713Z",
     "iopub.status.busy": "2026-09-03T10:13:20.654547Z",
     "iopub.status.idle": "2026-09-03T10:13:20.670291Z",
     "shell.execute_reply": "2026-09-03T10:13:20.669724Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'x': 1, 'o': 0, 'draws': 0}\n"
     ]
    }
   ],
   "source": [
    "def apply_round_result(scores, winner):\n",
    "    \"\"\"scores: {'x': int, 'o': int, 'draws': int}. winner: 'X' | 'O' | None.\"\"\"\n",
    "    scores = dict(scores)\n",
    "    if winner == \"X\":\n",
    "        scores[\"x\"] += 1\n",
    "    elif winner == \"O\":\n",
    "        scores[\"o\"] += 1\n",
    "    else:\n",
    "        scores[\"draws\"] += 1\n",
    "    return scores\n",
    "\n",
    "scores = {\"x\": 0, \"o\": 0, \"draws\": 0}\n",
    "scores = apply_round_result(scores, \"X\")\n",
    "print(scores)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "fd32c223",
   "metadata": {},
   "source": [
    "## Podstawowa praktyka zadań ★"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "df08dbd1",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-09-03T10:13:20.671704Z",
     "iopub.status.busy": "2026-09-03T10:13:20.671487Z",
     "iopub.status.idle": "2026-09-03T10:13:20.674463Z",
     "shell.execute_reply": "2026-09-03T10:13:20.673963Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Счёт обновляется верно для победы X, победы O и ничьей.\n"
     ]
    }
   ],
   "source": [
    "scores2 = {\"x\": 0, \"o\": 0, \"draws\": 0}\n",
    "scores2 = apply_round_result(scores2, \"X\")\n",
    "scores2 = apply_round_result(scores2, \"O\")\n",
    "scores2 = apply_round_result(scores2, None)  # ничья\n",
    "\n",
    "assert scores2 == {\"x\": 1, \"o\": 1, \"draws\": 1}\n",
    "print(\"Счёт обновляется верно для победы X, победы O и ничьей.\")"
   ]
  }
 ],
 "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
}
