Skip to content

Commit e216744

Browse files
String
1 parent f8b8e76 commit e216744

File tree

1 file changed

+137
-0
lines changed

1 file changed

+137
-0
lines changed

HackerRank/String/String.ipynb

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"# [Super Reduced String](https://www.hackerrank.com/challenges/reduced-string/problem)"
8+
]
9+
},
10+
{
11+
"cell_type": "code",
12+
"execution_count": 6,
13+
"metadata": {},
14+
"outputs": [
15+
{
16+
"name": "stdin",
17+
"output_type": "stream",
18+
"text": [
19+
" baab\n"
20+
]
21+
},
22+
{
23+
"name": "stdout",
24+
"output_type": "stream",
25+
"text": [
26+
"Empty String\n"
27+
]
28+
}
29+
],
30+
"source": [
31+
"s=input()\n",
32+
"for i in s:\n",
33+
" if s.count(i+i)>0:\n",
34+
" s=s.replace(i+i,'')\n",
35+
"if len(s)>0:\n",
36+
" print(s)\n",
37+
"else:\n",
38+
" print('Empty String')"
39+
]
40+
},
41+
{
42+
"cell_type": "markdown",
43+
"metadata": {},
44+
"source": [
45+
"# [Strong Password](https://www.hackerrank.com/challenges/strong-password/problem)"
46+
]
47+
},
48+
{
49+
"cell_type": "code",
50+
"execution_count": 4,
51+
"metadata": {},
52+
"outputs": [
53+
{
54+
"name": "stdin",
55+
"output_type": "stream",
56+
"text": [
57+
" HackerRank\n"
58+
]
59+
},
60+
{
61+
"name": "stdout",
62+
"output_type": "stream",
63+
"text": [
64+
"2\n"
65+
]
66+
}
67+
],
68+
"source": [
69+
"numbers = \"0123456789\"\n",
70+
"lower_case = \"abcdefghijklmnopqrstuvwxyz\"\n",
71+
"upper_case = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n",
72+
"special_characters = \"!@#$%^&*()-+\"\n",
73+
"\n",
74+
"c_digit=1\n",
75+
"c_lower=1\n",
76+
"c_upper=1\n",
77+
"c_speial=1\n",
78+
"\n",
79+
"s=input()\n",
80+
"for i in s:\n",
81+
" if i in numbers:\n",
82+
" if c_digit==1:\n",
83+
" c_digit-=1\n",
84+
" elif i in lower_case:\n",
85+
" if c_lower==1:\n",
86+
" c_lower-=1\n",
87+
" elif i in upper_case:\n",
88+
" if c_upper==1:\n",
89+
" c_upper-=1\n",
90+
" else:\n",
91+
" if c_speial==1:\n",
92+
" c_speial-=1\n",
93+
"print(max(c_digit+c_lower+c_speial+c_upper,6-len(s)))"
94+
]
95+
},
96+
{
97+
"cell_type": "code",
98+
"execution_count": null,
99+
"metadata": {},
100+
"outputs": [],
101+
"source": [
102+
"def minimumNumber(n, password):\n",
103+
" count = 0 \n",
104+
" if any(i.isdigit() for i in password)==False:\n",
105+
" count+=1\n",
106+
" if any(i.islower() for i in password)==False:\n",
107+
" count+=1\n",
108+
" if any(i.isupper() for i in password)==False:\n",
109+
" count+=1\n",
110+
" if any(i in '!@#$%^&*()-+' for i in password)==False:\n",
111+
" count+=1\n",
112+
" return max(count,6-n)"
113+
]
114+
}
115+
],
116+
"metadata": {
117+
"kernelspec": {
118+
"display_name": "Python 3",
119+
"language": "python",
120+
"name": "python3"
121+
},
122+
"language_info": {
123+
"codemirror_mode": {
124+
"name": "ipython",
125+
"version": 3
126+
},
127+
"file_extension": ".py",
128+
"mimetype": "text/x-python",
129+
"name": "python",
130+
"nbconvert_exporter": "python",
131+
"pygments_lexer": "ipython3",
132+
"version": "3.8.2"
133+
}
134+
},
135+
"nbformat": 4,
136+
"nbformat_minor": 4
137+
}

0 commit comments

Comments
 (0)