{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "192a5107",
   "metadata": {},
   "outputs": [],
   "source": [
    "%matplotlib inline\n",
    "\n",
    "import matplotlib.pyplot as plt\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "75aa6951",
   "metadata": {},
   "source": [
    "Vectorize this code"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "c912bb05",
   "metadata": {},
   "outputs": [],
   "source": [
    "size = 101\n",
    "center = size // 2\n",
    "radius = 20\n",
    "\n",
    "circle = np.zeros((size, size), dtype=float)\n",
    "for i in range(size):\n",
    "    for j in range(size):\n",
    "        distance_from_center = np.sqrt((i - center)**2 + (j - center)**2)\n",
    "        if distance_from_center <= radius:\n",
    "            circle[i, j] = 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "9bb5a50c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.image.AxesImage at 0x12490bdd0>"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 9928 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.imshow(circle)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1282ed4c",
   "metadata": {},
   "source": [
    "# Solution"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "a94b5623",
   "metadata": {},
   "outputs": [],
   "source": [
    "size = 101\n",
    "center = size // 2\n",
    "x = np.arange(size)\n",
    "y = x.reshape((size, 1))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c17f406b",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "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.11.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
