Skip to content

Commit 0e0c692

Browse files
HackerRank
1 parent e6e56a7 commit 0e0c692

File tree

10 files changed

+2177
-4
lines changed

10 files changed

+2177
-4
lines changed
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"# [Grading Students](https://www.hackerrank.com/challenges/grading/problem)"
8+
]
9+
},
10+
{
11+
"cell_type": "code",
12+
"execution_count": 1,
13+
"metadata": {},
14+
"outputs": [
15+
{
16+
"name": "stdin",
17+
"output_type": "stream",
18+
"text": [
19+
" 4\n",
20+
" 73\n"
21+
]
22+
},
23+
{
24+
"name": "stdout",
25+
"output_type": "stream",
26+
"text": [
27+
"75\n"
28+
]
29+
},
30+
{
31+
"name": "stdin",
32+
"output_type": "stream",
33+
"text": [
34+
" 67\n"
35+
]
36+
},
37+
{
38+
"name": "stdout",
39+
"output_type": "stream",
40+
"text": [
41+
"67\n"
42+
]
43+
},
44+
{
45+
"name": "stdin",
46+
"output_type": "stream",
47+
"text": [
48+
" 38\n"
49+
]
50+
},
51+
{
52+
"name": "stdout",
53+
"output_type": "stream",
54+
"text": [
55+
"40\n"
56+
]
57+
},
58+
{
59+
"name": "stdin",
60+
"output_type": "stream",
61+
"text": [
62+
" 33\n"
63+
]
64+
},
65+
{
66+
"name": "stdout",
67+
"output_type": "stream",
68+
"text": [
69+
"33\n"
70+
]
71+
}
72+
],
73+
"source": [
74+
"n=int(input())\n",
75+
"for i in range(n):\n",
76+
" n1=int(input())\n",
77+
" if n1>37:\n",
78+
" if (5-n1%5)<3:\n",
79+
" print(n1+5-n1%5)\n",
80+
" else:\n",
81+
" print(n1)\n",
82+
" else:\n",
83+
" print(n1)"
84+
]
85+
},
86+
{
87+
"cell_type": "code",
88+
"execution_count": null,
89+
"metadata": {},
90+
"outputs": [],
91+
"source": []
92+
}
93+
],
94+
"metadata": {
95+
"kernelspec": {
96+
"display_name": "Python 3",
97+
"language": "python",
98+
"name": "python3"
99+
},
100+
"language_info": {
101+
"codemirror_mode": {
102+
"name": "ipython",
103+
"version": 3
104+
},
105+
"file_extension": ".py",
106+
"mimetype": "text/x-python",
107+
"name": "python",
108+
"nbconvert_exporter": "python",
109+
"pygments_lexer": "ipython3",
110+
"version": "3.8.2"
111+
}
112+
},
113+
"nbformat": 4,
114+
"nbformat_minor": 4
115+
}
Lines changed: 282 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,282 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"# [Diagonal Difference](https://www.hackerrank.com/challenges/diagonal-difference/problem)"
8+
]
9+
},
10+
{
11+
"cell_type": "code",
12+
"execution_count": 9,
13+
"metadata": {},
14+
"outputs": [
15+
{
16+
"name": "stdout",
17+
"output_type": "stream",
18+
"text": [
19+
"2\n"
20+
]
21+
}
22+
],
23+
"source": [
24+
"'''\n",
25+
"1 2 3\n",
26+
"4 5 6\n",
27+
"9 8 9 \n",
28+
"'''\n",
29+
"a=[[1,2,3],[4,5,6],[9,8,9]]\n",
30+
"c=0\n",
31+
"for i in range(len(a)):\n",
32+
" c+=a[i][i]-a[i][len(a)-i-1]\n",
33+
"print(abs(c))"
34+
]
35+
},
36+
{
37+
"cell_type": "markdown",
38+
"metadata": {},
39+
"source": [
40+
"# [Plus Minus](https://www.hackerrank.com/challenges/plus-minus/problem)"
41+
]
42+
},
43+
{
44+
"cell_type": "code",
45+
"execution_count": 7,
46+
"metadata": {},
47+
"outputs": [
48+
{
49+
"name": "stdout",
50+
"output_type": "stream",
51+
"text": [
52+
"3\n",
53+
"5\n",
54+
"9\n"
55+
]
56+
}
57+
],
58+
"source": [
59+
"'''\n",
60+
"6\n",
61+
"-4 3 -9 0 4 1\n",
62+
"'''\n"
63+
]
64+
},
65+
{
66+
"cell_type": "code",
67+
"execution_count": 10,
68+
"metadata": {},
69+
"outputs": [
70+
{
71+
"name": "stdin",
72+
"output_type": "stream",
73+
"text": [
74+
" 6\n",
75+
" -4 3 -9 0 4 1\n"
76+
]
77+
},
78+
{
79+
"name": "stdout",
80+
"output_type": "stream",
81+
"text": [
82+
"0.5\n",
83+
"0.3333333333333333\n",
84+
"0.16666666666666666\n"
85+
]
86+
}
87+
],
88+
"source": [
89+
"n=int(input())\n",
90+
"a=list(map(int,input().split()))\n",
91+
"positive=0\n",
92+
"negative=0\n",
93+
"zero=0\n",
94+
"for i in a:\n",
95+
" if i>0:\n",
96+
" positive+=1\n",
97+
" elif i<0:\n",
98+
" negative+=1\n",
99+
" else:\n",
100+
" zero+=1\n",
101+
"print(f'{positive/n}\\n{negative/n}\\n{zero/n}')"
102+
]
103+
},
104+
{
105+
"cell_type": "markdown",
106+
"metadata": {},
107+
"source": [
108+
"# [Staircase](https://www.hackerrank.com/challenges/staircase/problem) "
109+
]
110+
},
111+
{
112+
"cell_type": "code",
113+
"execution_count": 12,
114+
"metadata": {},
115+
"outputs": [
116+
{
117+
"name": "stdin",
118+
"output_type": "stream",
119+
"text": [
120+
" 8\n"
121+
]
122+
},
123+
{
124+
"name": "stdout",
125+
"output_type": "stream",
126+
"text": [
127+
" #\n",
128+
" ##\n",
129+
" ###\n",
130+
" ####\n",
131+
" #####\n",
132+
" ######\n",
133+
" #######\n",
134+
"########\n"
135+
]
136+
}
137+
],
138+
"source": [
139+
"'''\n",
140+
" #\n",
141+
" ##\n",
142+
" ###\n",
143+
"####\n",
144+
"'''\n",
145+
"n=int(input())\n",
146+
"for i in range(n):\n",
147+
" print(' '*(n-i-1),'#'*(i+1),sep='')"
148+
]
149+
},
150+
{
151+
"cell_type": "markdown",
152+
"metadata": {},
153+
"source": [
154+
"# [Mini-Max Sum](https://www.hackerrank.com/challenges/mini-max-sum/problem)"
155+
]
156+
},
157+
{
158+
"cell_type": "code",
159+
"execution_count": 14,
160+
"metadata": {},
161+
"outputs": [
162+
{
163+
"name": "stdin",
164+
"output_type": "stream",
165+
"text": [
166+
" 1 2 3 4 5\n"
167+
]
168+
},
169+
{
170+
"name": "stdout",
171+
"output_type": "stream",
172+
"text": [
173+
"10 14\n"
174+
]
175+
}
176+
],
177+
"source": [
178+
"a=list(map(int,input().split()))\n",
179+
"a.sort()\n",
180+
"print(sum(a[:-1]),sum(a[1:]))"
181+
]
182+
},
183+
{
184+
"cell_type": "markdown",
185+
"metadata": {},
186+
"source": [
187+
"# [Birthday Cake Candles](https://www.hackerrank.com/challenges/birthday-cake-candles/problem)"
188+
]
189+
},
190+
{
191+
"cell_type": "code",
192+
"execution_count": 18,
193+
"metadata": {},
194+
"outputs": [
195+
{
196+
"name": "stdin",
197+
"output_type": "stream",
198+
"text": [
199+
" 4\n",
200+
" 3 2 1 3\n"
201+
]
202+
},
203+
{
204+
"name": "stdout",
205+
"output_type": "stream",
206+
"text": [
207+
"2\n"
208+
]
209+
}
210+
],
211+
"source": [
212+
"n=int(input())\n",
213+
"a=list(map(int,input().split()))\n",
214+
"print(a.count(max(a)))"
215+
]
216+
},
217+
{
218+
"cell_type": "markdown",
219+
"metadata": {},
220+
"source": [
221+
"# [Time Conversion](https://www.hackerrank.com/challenges/time-conversion/problem)"
222+
]
223+
},
224+
{
225+
"cell_type": "code",
226+
"execution_count": 28,
227+
"metadata": {},
228+
"outputs": [
229+
{
230+
"name": "stdin",
231+
"output_type": "stream",
232+
"text": [
233+
" 07:05:45PM\n"
234+
]
235+
},
236+
{
237+
"name": "stdout",
238+
"output_type": "stream",
239+
"text": [
240+
"19:05:45\n"
241+
]
242+
}
243+
],
244+
"source": [
245+
"'07:05:45PM'\n",
246+
"s=input()\n",
247+
"hh=int(s[:2])%12\n",
248+
"if s[-2:]=='PM':\n",
249+
" hh+=12\n",
250+
"print(str(hh)+s[2:-2])"
251+
]
252+
},
253+
{
254+
"cell_type": "code",
255+
"execution_count": null,
256+
"metadata": {},
257+
"outputs": [],
258+
"source": []
259+
}
260+
],
261+
"metadata": {
262+
"kernelspec": {
263+
"display_name": "Python 3",
264+
"language": "python",
265+
"name": "python3"
266+
},
267+
"language_info": {
268+
"codemirror_mode": {
269+
"name": "ipython",
270+
"version": 3
271+
},
272+
"file_extension": ".py",
273+
"mimetype": "text/x-python",
274+
"name": "python",
275+
"nbconvert_exporter": "python",
276+
"pygments_lexer": "ipython3",
277+
"version": "3.8.2"
278+
}
279+
},
280+
"nbformat": 4,
281+
"nbformat_minor": 4
282+
}

0 commit comments

Comments
 (0)