Skip to content

Commit 8f3e90b

Browse files
committed
numpy
1 parent 8577b9a commit 8f3e90b

File tree

1 file changed

+71
-1
lines changed

1 file changed

+71
-1
lines changed

numpy.ipynb

+71-1
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,79 @@
200200
},
201201
{
202202
"cell_type": "code",
203-
"execution_count": null,
203+
"execution_count": 1,
204204
"id": "ae81dca2",
205205
"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": {},
206276
"outputs": [],
207277
"source": []
208278
}

0 commit comments

Comments
 (0)