{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "7d0348f0",
   "metadata": {},
   "source": [
    "# 19-09 · Świat gry jako siatka\n",
    "\n",
    "Praktyka do sekcji [„Świat gry jako siatka”"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8804c691",
   "metadata": {},
   "source": [
    "## Cel\n",
    "\n",
    "Określić, czy punkt leży na siatce w krokach STEP."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "deb9d081",
   "metadata": {},
   "source": [
    "## Sprawa robocza"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "1ed4d045",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-09-03T00:53:36.283748Z",
     "iopub.status.busy": "2026-09-03T00:53:36.283567Z",
     "iopub.status.idle": "2026-09-03T00:53:36.310528Z",
     "shell.execute_reply": "2026-09-03T00:53:36.309990Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "True\n",
      "False\n"
     ]
    }
   ],
   "source": [
    "STEP = 20\n",
    "\n",
    "def is_on_grid(x, y, step=STEP):\n",
    "    return x % step == 0 and y % step == 0\n",
    "\n",
    "print(is_on_grid(40, -60))\n",
    "print(is_on_grid(41, -60))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "98cf499f",
   "metadata": {},
   "source": [
    "## Podstawowa praktyka zadań ★"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "b85aaea6",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-09-03T00:53:36.312368Z",
     "iopub.status.busy": "2026-09-03T00:53:36.312184Z",
     "iopub.status.idle": "2026-09-03T00:53:36.316858Z",
     "shell.execute_reply": "2026-09-03T00:53:36.316413Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Легальные позиции определены верно.\n"
     ]
    }
   ],
   "source": [
    "assert is_on_grid(0, 0) is True\n",
    "assert is_on_grid(-280, 280) is True\n",
    "assert is_on_grid(21, 0) is False\n",
    "assert is_on_grid(0, -5) is False\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
}
