update on more code
swadhinbiswas committed 1 years ago
72d8a7a
1 parent 4beca37
commit 72d8a7a
6 files changed
+178 -4
Showing 6 changed files+178-4
▼Codeforces/A. Way Too Long Words.py
+20-0
| @@ -0,0 +1,20 @@ | ||
1 | +class Solve: | |
2 | + def toolong(word:str)->None: | |
3 | + | |
4 | + | |
5 | + x:int=word.__len__() | |
6 | + | |
7 | + if x>10: | |
8 | + finalword=f'{word[:1]}{x-2}{word[-1:]}' | |
9 | + print(finalword) | |
10 | + else: | |
11 | + print(word) | |
12 | + | |
13 | + | |
14 | + | |
15 | + | |
16 | +if __name__ == '__main__': | |
17 | + testcase:int=int(input()) | |
18 | + for i in range(testcase): | |
19 | + word:str=str(input()) | |
20 | + Solve.toolong(word) | |
0 | 21 | |
▼Codeforces/watermelon.py
+13-4
| @@ -1,9 +1,18 @@ | ||
1 | -x=int(input()) | |
2 | 1 | |
3 | -if x<=100: | |
4 | - if x%2==0: | |
2 | +def watermellon(weight): | |
3 | + if weight<=100: | |
4 | + if weight%2==0 and weight>2: | |
5 | 5 | print("YES") |
6 | - else: | |
6 | + else: | |
7 | 7 | print("NO") |
8 | + else: | |
9 | + return -1 | |
10 | + | |
11 | +if __name__ == "__main__": | |
12 | + weight=int(input()) | |
13 | + watermellon(weight) | |
14 | + | |
15 | + | |
16 | + | |
8 | 17 | |
9 | 18 | |
10 | 19 | |
▼Toph.co/Byang's Day Out!.py
+0-0
0 | 0 |
▼Toph.co/Not As Hard As It Seems.py
+15-0
| @@ -0,0 +1,15 @@ | ||
1 | +while(True): | |
2 | + try: | |
3 | + s=input() | |
4 | + a=0; x=0; t=[] | |
5 | + for n in range(len(s)): | |
6 | + if s[n]=='(' or s[n]=='[': t.append(s[n]) | |
7 | + elif len(t): | |
8 | + if (s[n]==')' and t[len(t)-1]=='(') or (s[n]==']' and t[len(t)-1] == '['): | |
9 | + t.pop(); x+=2; a=max(a,x) | |
10 | + if(len(t)==0): x=0 | |
11 | + else: | |
12 | + t.clear(); x=0 | |
13 | + print(a) | |
14 | + except EOFError: break | |
15 | + | |
0 | 16 | |
▼Toph.co/StrangePattern.py
+20-0
| @@ -0,0 +1,20 @@ | ||
1 | +n,m=input().split() | |
2 | +n=int(n) | |
3 | +m=int(m) | |
4 | +array=[] | |
5 | +for i in range(n): | |
6 | + arr2=list(map(str, input().split(",")))[:n] | |
7 | + array.append(arr2) | |
8 | + | |
9 | + | |
10 | +for index,row in enumerate(array): | |
11 | + stars=row[0].count('*') | |
12 | + if stars==m: | |
13 | + print(index+1) | |
14 | + break | |
15 | + | |
16 | + | |
17 | + | |
18 | + | |
19 | + | |
20 | + | |
0 | 21 | |
▼Toph.co/test.ipynb
+110-0
| @@ -0,0 +1,110 @@ | ||
1 | +{ | |
2 | + "cells": [ | |
3 | + { | |
4 | + "cell_type": "code", | |
5 | + "execution_count": 7, | |
6 | + "metadata": {}, | |
7 | + "outputs": [ | |
8 | + { | |
9 | + "name": "stdout", | |
10 | + "output_type": "stream", | |
11 | + "text": [ | |
12 | + "10\n", | |
13 | + "10\n", | |
14 | + "10\n", | |
15 | + "8\n" | |
16 | + ] | |
17 | + } | |
18 | + ], | |
19 | + "source": [ | |
20 | + "# # Get n and m from first line\n", | |
21 | + "# n, m = map(int, input().split())\n", | |
22 | + "# print(f\"n={n}, m={m}\") # Debug print\n", | |
23 | + "\n", | |
24 | + "# # Initialize empty array for the grid\n", | |
25 | + "# array = []\n", | |
26 | + "\n", | |
27 | + "# # Read n lines\n", | |
28 | + "# for i in range(n):\n", | |
29 | + "# arr2 = input().split(\",\")\n", | |
30 | + "# array.append(arr2)\n", | |
31 | + "# print(f\"Row {i}: {arr2}\") # Debug print\n", | |
32 | + "\n", | |
33 | + "# print(\"Full array:\", array) # Debug print\n", | |
34 | + "\n", | |
35 | + "# # Search for row with exactly m stars\n", | |
36 | + "# for row in array:\n", | |
37 | + "# star_count = row.count(\"*\")\n", | |
38 | + "# print(f\"Checking row {row}, star count: {star_count}\") # Debug print\n", | |
39 | + "# if star_count == m:\n", | |
40 | + "# print(\"Found matching row:\", row)\n", | |
41 | + "# break\n", | |
42 | + "\n", | |
43 | + "\n", | |
44 | + "\n", | |
45 | + "\n", | |
46 | + "\n", | |
47 | + "# x='**********.......***87675654534343*******************************'\n", | |
48 | + "\n", | |
49 | + "\n", | |
50 | + "# print(x.count('*'))\n", | |
51 | + "\n", | |
52 | + "x=[['**********'], ['**********'], ['**********'], ['********']]\n", | |
53 | + "\n", | |
54 | + "for i in x :\n", | |
55 | + " count = i[0].count('*')\n", | |
56 | + " print(count)\n", | |
57 | + "\n" | |
58 | + ] | |
59 | + }, | |
60 | + { | |
61 | + "cell_type": "code", | |
62 | + "execution_count": 1, | |
63 | + "metadata": {}, | |
64 | + "outputs": [], | |
65 | + "source": [ | |
66 | + "class Solve:\n", | |
67 | + " def toolong(word:str)->None:\n", | |
68 | + " \n", | |
69 | + " \n", | |
70 | + " x:int=word.__len__()\n", | |
71 | + "\n", | |
72 | + " if x>10:\n", | |
73 | + " finalword=f'{word[:1]}{x-2}{word[-1:]}'\n", | |
74 | + " print(finalword)\n", | |
75 | + " else:\n", | |
76 | + " print(word)\n", | |
77 | + "\n", | |
78 | + "\n", | |
79 | + "\n", | |
80 | + "\n", | |
81 | + "if __name__ == '__main__':\n", | |
82 | + " testcase:int=int(input())\n", | |
83 | + " for i in range(testcase):\n", | |
84 | + " word:str=str(input())\n", | |
85 | + " Solve.toolong(word)\n" | |
86 | + ] | |
87 | + } | |
88 | + ], | |
89 | + "metadata": { | |
90 | + "kernelspec": { | |
91 | + "display_name": "Python 3", | |
92 | + "language": "python", | |
93 | + "name": "python3" | |
94 | + }, | |
95 | + "language_info": { | |
96 | + "codemirror_mode": { | |
97 | + "name": "ipython", | |
98 | + "version": 3 | |
99 | + }, | |
100 | + "file_extension": ".py", | |
101 | + "mimetype": "text/x-python", | |
102 | + "name": "python", | |
103 | + "nbconvert_exporter": "python", | |
104 | + "pygments_lexer": "ipython3", | |
105 | + "version": "3.11.8" | |
106 | + } | |
107 | + }, | |
108 | + "nbformat": 4, | |
109 | + "nbformat_minor": 2 | |
110 | +} | |
0 | 111 | |