{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "388c3d8e",
   "metadata": {},
   "source": [
    "# 16-15 · Адаптивный grid\n",
    "\n",
    "Практика к разделу [«Адаптивный grid: sticky и weight»](../../site/chapters/glava-16/16-15-adaptivny-grid.html)."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b66a02c2",
   "metadata": {},
   "source": [
    "## Цель\n",
    "\n",
    "Понять, как вес столбца распределяет дополнительное пространство."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "645c4f13",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-18T21:45:13.176243Z",
     "iopub.status.busy": "2026-08-18T21:45:13.176125Z",
     "iopub.status.idle": "2026-08-18T21:45:13.192623Z",
     "shell.execute_reply": "2026-08-18T21:45:13.192055Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[100.0, 100.0] [100.0, 200.0]\n"
     ]
    }
   ],
   "source": [
    "def raspredelit_prostranstvo(weights, extra_space):\n",
    "    total = sum(weights)\n",
    "    if total == 0:\n",
    "        return [0] * len(weights)\n",
    "    return [extra_space * w / total for w in weights]\n",
    "\n",
    "result_equal = raspredelit_prostranstvo([1, 1], 200)\n",
    "result_weighted = raspredelit_prostranstvo([1, 2], 300)\n",
    "print(result_equal, result_weighted)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "15b86bf7",
   "metadata": {},
   "source": [
    "## Задание ★ Базовая практика\n",
    "\n",
    "Проверьте распределение для трёх колонок с весами [1, 1, 2] и 400 пикселями лишнего места."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "f2e7bd16",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-18T21:45:13.193669Z",
     "iopub.status.busy": "2026-08-18T21:45:13.193541Z",
     "iopub.status.idle": "2026-08-18T21:45:13.195803Z",
     "shell.execute_reply": "2026-08-18T21:45:13.195387Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[100.0, 100.0, 200.0]\n"
     ]
    }
   ],
   "source": [
    "result_three = raspredelit_prostranstvo([1, 1, 2], 400)\n",
    "print(result_three)"
   ]
  }
 ],
 "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
}
