Skip to content

Commit 1e105e1

Browse files
committed
Updated new tasks and solution to existing ones.
1 parent 41b22e3 commit 1e105e1

18 files changed

+955
-33
lines changed

Tasks/0003.ipynb

+69-4
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,80 @@
7070
},
7171
{
7272
"cell_type": "code",
73-
"execution_count": null,
73+
"execution_count": 1,
7474
"metadata": {},
75-
"outputs": [],
75+
"outputs": [
76+
{
77+
"name": "stdout",
78+
"output_type": "stream",
79+
"text": [
80+
"1 is the smallest\n"
81+
]
82+
}
83+
],
84+
"source": [
85+
"arr=[5, 6, 7, 8, 9, 10, 11, 1, 2, 3, 4]\n",
86+
"start=0\n",
87+
"end=len(arr)-1\n",
88+
"\n",
89+
"while(start<end):\n",
90+
"\tif(arr[start]>arr[end]):\n",
91+
"\t\tstart=(start+end)//2\n",
92+
"\telse:\n",
93+
"\t\tend=(start+end)//2\n",
94+
"\n",
95+
"print(\"{} is the smallest\".format(arr[start]))"
96+
]
97+
},
98+
{
99+
"cell_type": "code",
100+
"execution_count": 3,
101+
"metadata": {},
102+
"outputs": [
103+
{
104+
"name": "stdout",
105+
"output_type": "stream",
106+
"text": [
107+
"3\n"
108+
]
109+
}
110+
],
111+
"source": [
112+
"a,p=[5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 3, 4],-1\n",
113+
"for i in range(len(a)//2+1):\n",
114+
"\tif a[i]==a[p]:\n",
115+
"\t\tprint(a[i+1])\n",
116+
"\t\tbreak\n",
117+
"\telif a[i]<a[p]:\n",
118+
"\t\tprint(a[p+1])\n",
119+
"\t\tbreak\n",
120+
"\tp-=1"
121+
]
122+
},
123+
{
124+
"cell_type": "code",
125+
"execution_count": 10,
126+
"metadata": {},
127+
"outputs": [
128+
{
129+
"name": "stdout",
130+
"output_type": "stream",
131+
"text": [
132+
"-1\n",
133+
"-2\n",
134+
"-3\n",
135+
"-4\n",
136+
"-5\n",
137+
"1\n"
138+
]
139+
}
140+
],
76141
"source": [
77142
"# By --- ʀᴏʜɪᴛʜ ᴋᴜᴍᴀʀ\n",
78143
"\n",
79144
"a,p=[5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 1, 2, 3, 4],0\n",
80-
"a,p=[4,5,6,0,1,2,3],0\n",
81-
"a=[12, 13, 14, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]\n",
145+
"#a,p=[4,5,6,1,2,3],0\n",
146+
"#a=[12, 13, 14, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]\n",
82147
"\n",
83148
"l,x=len(a)//2+1,a[0]+a[-1]\n",
84149
"for i in range(l):\n",

Tasks/0004.ipynb

+10-10
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
},
1818
{
1919
"cell_type": "code",
20-
"execution_count": 5,
20+
"execution_count": 1,
2121
"metadata": {
2222
"scrolled": true
2323
},
@@ -26,24 +26,24 @@
2626
"name": "stdout",
2727
"output_type": "stream",
2828
"text": [
29-
"maDAm\n",
30-
"False\n"
29+
"maDAM\n",
30+
"True\n"
3131
]
3232
}
3333
],
3434
"source": [
3535
"# By --- ʀᴏʜɪᴛʜ ᴋᴜᴍᴀʀ\n",
3636
"\n",
37-
"s=input()\n",
37+
"s=input().lower()\n",
3838
"nr,c=set(s),0\n",
3939
"for i in nr:\n",
40-
" if s.count(i)%2:\n",
41-
" c+=1\n",
42-
" if c>1:\n",
43-
" print(False)\n",
44-
" break\n",
40+
"\tif s.count(i)%2:\n",
41+
"\t\tc+=1\n",
42+
"\tif c>1:\n",
43+
"\t\tprint(False)\n",
44+
"\t\tbreak\n",
4545
"if c<=1:\n",
46-
" print(True)\n"
46+
"\tprint(True)"
4747
]
4848
},
4949
{

Tasks/0005.ipynb

+37
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,43 @@
1313
"\n",
1414
"#python #practiceCode #samples #interviewQuestions #collections #list #algorithm"
1515
]
16+
},
17+
{
18+
"cell_type": "code",
19+
"execution_count": 6,
20+
"metadata": {},
21+
"outputs": [
22+
{
23+
"name": "stdout",
24+
"output_type": "stream",
25+
"text": [
26+
"Enter the first string:hello how are you\n",
27+
"Enter the second string:how are you hello\n",
28+
"Two strings are permutation of each other\n"
29+
]
30+
}
31+
],
32+
"source": [
33+
"# By Avisek\n",
34+
"\n",
35+
"str1=input(\"Enter the first string:\").upper()\n",
36+
"str2=input(\"Enter the second string:\").upper()\n",
37+
"list1=str1.split()\n",
38+
"list2=str2.split()\n",
39+
"flag=True\n",
40+
"for i in list1:\n",
41+
" if i not in list2:\n",
42+
" flag=False\n",
43+
" break\n",
44+
" else:\n",
45+
" list2.remove(i)\n",
46+
" \n",
47+
"\n",
48+
"if flag:\n",
49+
" print(\"Two strings are permutation of each other\")\n",
50+
"else:\n",
51+
" print(\"Two strings are different\")"
52+
]
1653
}
1754
],
1855
"metadata": {

Tasks/0006.ipynb

+61-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"cells": [
33
{
4-
"attachments": {},
54
"cell_type": "markdown",
65
"metadata": {},
76
"source": [
@@ -16,6 +15,67 @@
1615
"\n",
1716
"#python #practiceCode #samples #interviewQuestions #collections #dict #algorithm"
1817
]
18+
},
19+
{
20+
"cell_type": "code",
21+
"execution_count": 1,
22+
"metadata": {
23+
"scrolled": true
24+
},
25+
"outputs": [
26+
{
27+
"name": "stdout",
28+
"output_type": "stream",
29+
"text": [
30+
"programming favourite language Python. My is \n"
31+
]
32+
}
33+
],
34+
"source": [
35+
"# By Krat0s\n",
36+
"\n",
37+
"val= \"My favourite programming language is Python.\"\n",
38+
"n_val,b,max=val.split(),\"\",\"\"\n",
39+
"for a in range(len(n_val)):\n",
40+
" for i in range(len(n_val)):\n",
41+
" if len(max) < len(n_val[i]):\n",
42+
" max=n_val[i]\n",
43+
" b+=max+\" \"\n",
44+
" del n_val[n_val.index(max)]\n",
45+
" max=\"\"\n",
46+
"print(b)"
47+
]
48+
},
49+
{
50+
"cell_type": "code",
51+
"execution_count": 2,
52+
"metadata": {},
53+
"outputs": [
54+
{
55+
"name": "stdout",
56+
"output_type": "stream",
57+
"text": [
58+
"Enter the first string:My favourite programming language is Python.\n",
59+
"programming favourite language Python. is My \n"
60+
]
61+
}
62+
],
63+
"source": [
64+
"# By Avisek Mayur\n",
65+
"\n",
66+
"str1=input(\"Enter the first string:\")\n",
67+
"list1=str1.split() \n",
68+
"\n",
69+
"for i in range(len(list1)):\n",
70+
" for j in range(i+1,len(list1)):\n",
71+
" if len(list1[i])<len(list1[j]):\n",
72+
" list1[i],list1[j]=list1[j],list1[i]\n",
73+
"\n",
74+
"str1=\"\"\n",
75+
"for i in list1:\n",
76+
" str1+=i+\" \"\n",
77+
"print(str1)"
78+
]
1979
}
2080
],
2181
"metadata": {

Tasks/0007.ipynb

+27
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,33 @@
1515
"\n",
1616
"#python #practiceCode #samples #interviewQuestions #collections #algorithm"
1717
]
18+
},
19+
{
20+
"cell_type": "code",
21+
"execution_count": 1,
22+
"metadata": {},
23+
"outputs": [
24+
{
25+
"name": "stdout",
26+
"output_type": "stream",
27+
"text": [
28+
"Enter a string:xxXXXXXAAABBcCDDDEEEEccc\n",
29+
"x2X5A3B2c4C1D3E4\n"
30+
]
31+
}
32+
],
33+
"source": [
34+
"# Solution provided by --- Avisek Mayur\n",
35+
"\n",
36+
"# Not the solution what was expected.\n",
37+
"\n",
38+
"str1=input(\"Enter a string:\")\n",
39+
"str2=\"\"\n",
40+
"for i in str1:\n",
41+
" if i not in str2:\n",
42+
" str2+=i+str(str1.count(i))\n",
43+
"print(str2)"
44+
]
1845
}
1946
],
2047
"metadata": {

Tasks/0008.ipynb

+22-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"cells": [
33
{
4-
"attachments": {},
54
"cell_type": "markdown",
65
"metadata": {},
76
"source": [
@@ -25,10 +24,29 @@
2524
},
2625
{
2726
"cell_type": "code",
28-
"execution_count": null,
27+
"execution_count": 2,
2928
"metadata": {},
30-
"outputs": [],
31-
"source": []
29+
"outputs": [
30+
{
31+
"name": "stdout",
32+
"output_type": "stream",
33+
"text": [
34+
"Enter bottle capacity:1\n",
35+
"3.0 ltrs\n"
36+
]
37+
}
38+
],
39+
"source": [
40+
"# Solution provided by --- Avisek Mayur\n",
41+
"\n",
42+
"bottle=[5,4,10,0,8,7,6]\n",
43+
"cap=int(input(\"Enter bottle capacity:\"))\n",
44+
"need=0\n",
45+
"for i in bottle:\n",
46+
" need+=cap*(10-i)\n",
47+
"need=need/10\n",
48+
"print(need,'ltrs')"
49+
]
3250
}
3351
],
3452
"metadata": {

0 commit comments

Comments
 (0)