update on leadcode

swadhinbiswas committed 1 years ago
0b222ff
1 parent 0672196
commit 0b222ff
7 files changed
+217 -3
▼DSA/Arrays/pass.py
+0-0
0
0
▼DSA/Binary NuberSystem/DectoBinary.py
+23-0
1
+class Solve:
2
+ def convertToBinary(number:int):
3
+ ans:float=0
4
+ power:int=1
5
+
6
+ while number>0:
7
+ rem=number%2
8
+ number//=2
9
+ ans+=(rem*power)
10
+ power*=10
11
+
12
+ return ans
13
+
14
+
15
+
16
+
17
+if __name__ == "__main__":
18
+ number=50
19
+ x=Solve.convertToBinary(number=number)
20
+ print(x)
21
+
22
+
23
+
0
24
▼DSA/Binary NuberSystem/OctatoDec.py
+20-0
1
+class Solve:
2
+ def convertToBinary(number:int):
3
+ ans:float=0
4
+ power:int=1
5
+
6
+ while number>0:
7
+ rem=number%2
8
+ number//=2
9
+ ans+=(rem*power)
10
+ power*=10
11
+
12
+ return ans
13
+
14
+
15
+
16
+
17
+if __name__ == "__main__":
18
+ number=50
19
+ x=Solve.convertToBinary(number=number)
20
+ print(x)
0
21
▼DSA/Traingle.cpp
+21-0
1
+#include <iostream>
2
+using namespace std;
3
+
4
+int main() {
5
+ int n = 4;
6
+ for (int i = 0; i < n; i++) {
7
+ // Corrected the inner loop condition
8
+ for (int j = 0; j < n - i - 1; j++) {
9
+ cout << " ";
10
+ }
11
+ for (int j = 1; j <= i + 1; j++) {
12
+ cout << j;
13
+ }
14
+ // Corrected the inner loop condition and initialization
15
+ for (int j = i; j > 0; j--) {
16
+ cout << j;
17
+ }
18
+ cout << endl;
19
+ }
20
+ return 0; // Added return statement
21
+}
0
22
▼DSA/a.out
+0-0
Binary file not shown.
▼DSA/test.ipynb
+87-0
1
+{
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": 3,
6
+ "metadata": {},
7
+ "outputs": [
8
+ {
9
+ "name": "stdout",
10
+ "output_type": "stream",
11
+ "text": [
12
+ "25\n"
13
+ ]
14
+ }
15
+ ],
16
+ "source": [
17
+ "# x=[]\n",
18
+ "\n",
19
+ "# x.append(2)\n",
20
+ "# x.append(3)\n",
21
+ "# x.append(4)\n",
22
+ "# x.append(5)\n",
23
+ "# print(x)\n",
24
+ "# x.pop\n",
25
+ "\n",
26
+ "x=5\n",
27
+ "print(x**2)"
28
+ ]
29
+ },
30
+ {
31
+ "cell_type": "code",
32
+ "execution_count": 7,
33
+ "metadata": {},
34
+ "outputs": [
35
+ {
36
+ "name": "stdout",
37
+ "output_type": "stream",
38
+ "text": [
39
+ "101101\n"
40
+ ]
41
+ }
42
+ ],
43
+ "source": [
44
+ "x=45\n",
45
+ "print(bin(x)[2:])"
46
+ ]
47
+ },
48
+ {
49
+ "cell_type": "code",
50
+ "execution_count": 21,
51
+ "metadata": {},
52
+ "outputs": [
53
+ {
54
+ "name": "stdout",
55
+ "output_type": "stream",
56
+ "text": [
57
+ "-6\n"
58
+ ]
59
+ }
60
+ ],
61
+ "source": [
62
+ "print(-12>>1)"
63
+ ]
64
+ }
65
+ ],
66
+ "metadata": {
67
+ "kernelspec": {
68
+ "display_name": "Python 3",
69
+ "language": "python",
70
+ "name": "python3"
71
+ },
72
+ "language_info": {
73
+ "codemirror_mode": {
74
+ "name": "ipython",
75
+ "version": 3
76
+ },
77
+ "file_extension": ".py",
78
+ "mimetype": "text/x-python",
79
+ "name": "python",
80
+ "nbconvert_exporter": "python",
81
+ "pygments_lexer": "ipython3",
82
+ "version": "3.11.8"
83
+ }
84
+ },
85
+ "nbformat": 4,
86
+ "nbformat_minor": 2
87
+}
0
88
▼Toph.co/test.ipynb
+66-3
288
288
},
289
289
{
290
290
"cell_type": "code",
291
- "execution_count": null,
291
+ "execution_count": 8,
292
292
"metadata": {},
293
- "outputs": [],
293
+ "outputs": [
294
+ {
295
+ "name": "stdout",
296
+ "output_type": "stream",
297
+ "text": [
298
+ "10\n",
299
+ "121\n",
300
+ "1232\n",
301
+ "12343\n"
302
+ ]
303
+ }
304
+ ],
294
305
"source": [
295
- " "
306
+ " ## Uclide Peramide\n",
307
+ "\n",
308
+ "rows=4\n",
309
+ "pattern = []\n",
310
+ "for i in range(1, rows + 1):\n",
311
+ " row = \"\"\n",
312
+ " for j in range(1, i + 1):\n",
313
+ " row += str(j)\n",
314
+ " row += str(i - 1)[::-1] \n",
315
+ " pattern.append(row)\n",
316
+ "\n",
317
+ "\n",
318
+ "for row in pattern:\n",
319
+ " print(row)\n",
320
+ "\n",
321
+ "\n"
322
+ ]
323
+ },
324
+ {
325
+ "cell_type": "code",
326
+ "execution_count": 9,
327
+ "metadata": {},
328
+ "outputs": [
329
+ {
330
+ "name": "stdout",
331
+ "output_type": "stream",
332
+ "text": [
333
+ " 1 12 1 123 211234 321"
334
+ ]
335
+ }
336
+ ],
337
+ "source": [
338
+ "# Holo Dimond print\n",
339
+ "n = 4\n",
340
+ "\n",
341
+ "for i in range(n):\n",
342
+ " # Print spaces for the top part\n",
343
+ " for j in range(n - i - 1):\n",
344
+ " print(\" \", end=\"\")\n",
345
+ "\n",
346
+ " # Print numbers for the top part\n",
347
+ " for j in range(i + 1):\n",
348
+ " print(j + 1, end=\"\")\n",
349
+ "\n",
350
+ " # Print spaces for the bottom part (if not the first row)\n",
351
+ " if i != 0:\n",
352
+ " for j in range(2 * i - 1):\n",
353
+ " print(\" \", end=\"\")\n",
354
+ "\n",
355
+ " # Print numbers for the bottom part (if not the first row)\n",
356
+ " if i != 0:\n",
357
+ " for j in range(i, 0, -1):\n",
358
+ " print(j, end=\"\")"
296
359
]
297
360
}
298
361
],
299
362