|
200 | 200 | },
|
201 | 201 | {
|
202 | 202 | "cell_type": "code",
|
203 |
| - "execution_count": null, |
| 203 | + "execution_count": 1, |
204 | 204 | "id": "ae81dca2",
|
205 | 205 | "metadata": {},
|
| 206 | + "outputs": [ |
| 207 | + { |
| 208 | + "name": "stdout", |
| 209 | + "output_type": "stream", |
| 210 | + "text": [ |
| 211 | + "Star Patterns:\n", |
| 212 | + "\n", |
| 213 | + "Patterns for 1 stars:\n", |
| 214 | + "*\n", |
| 215 | + "\n", |
| 216 | + "Patterns for 2 stars:\n", |
| 217 | + "**\n", |
| 218 | + "\n", |
| 219 | + "*\n", |
| 220 | + "*\n", |
| 221 | + "\n", |
| 222 | + "Patterns for 3 stars:\n", |
| 223 | + "***\n", |
| 224 | + "\n", |
| 225 | + "*\n", |
| 226 | + "*\n", |
| 227 | + "*\n", |
| 228 | + "\n", |
| 229 | + "Patterns for 4 stars:\n", |
| 230 | + "****\n", |
| 231 | + "\n", |
| 232 | + "**\n", |
| 233 | + "**\n", |
| 234 | + "\n", |
| 235 | + "*\n", |
| 236 | + "*\n", |
| 237 | + "*\n", |
| 238 | + "*\n", |
| 239 | + "\n" |
| 240 | + ] |
| 241 | + } |
| 242 | + ], |
| 243 | + "source": [ |
| 244 | + "from math import isqrt\n", |
| 245 | + "import numpy as np;\n", |
| 246 | + "\n", |
| 247 | + "# Arrays\n", |
| 248 | + "array1 = [2, 3, 4]\n", |
| 249 | + "array2 = [1, 2, 3]\n", |
| 250 | + "\n", |
| 251 | + "# Union and sort\n", |
| 252 | + "union_array = sorted(set(array1 + array2))\n", |
| 253 | + "\n", |
| 254 | + "print(\"Star Patterns:\\n\")\n", |
| 255 | + "\n", |
| 256 | + "# Function to print a star block of given rows and cols\n", |
| 257 | + "def print_block(rows, cols):\n", |
| 258 | + " for _ in range(rows):\n", |
| 259 | + " print(\"*\" * cols)\n", |
| 260 | + " print()\n", |
| 261 | + "\n", |
| 262 | + "# Generate all rectangle patterns for each number\n", |
| 263 | + "for num in union_array:\n", |
| 264 | + " print(f\"Patterns for {num} stars:\")\n", |
| 265 | + " for rows in range(1, num + 1):\n", |
| 266 | + " if num % rows == 0:\n", |
| 267 | + " cols = num // rows\n", |
| 268 | + " print_block(rows, cols)\n" |
| 269 | + ] |
| 270 | + }, |
| 271 | + { |
| 272 | + "cell_type": "code", |
| 273 | + "execution_count": null, |
| 274 | + "id": "f46bcf33", |
| 275 | + "metadata": {}, |
206 | 276 | "outputs": [],
|
207 | 277 | "source": []
|
208 | 278 | }
|
|
0 commit comments