Skip to content

Commit 903e833

Browse files
committed
Selection Sort MAP
1 parent 7d35a2c commit 903e833

File tree

1 file changed

+83
-6
lines changed

1 file changed

+83
-6
lines changed

Pract.ipynb

Lines changed: 83 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -167,17 +167,94 @@
167167
},
168168
{
169169
"cell_type": "code",
170-
"execution_count": null,
170+
"execution_count": 2,
171171
"metadata": {},
172-
"outputs": [],
173-
"source": []
172+
"outputs": [
173+
{
174+
"name": "stdin",
175+
"output_type": "stream",
176+
"text": [
177+
" 3\n",
178+
" 2\n",
179+
" 4\n",
180+
" 1\n",
181+
" 2\n"
182+
]
183+
},
184+
{
185+
"name": "stdout",
186+
"output_type": "stream",
187+
"text": [
188+
"[3, 2, 4, 1, 2]\n",
189+
"[1, 2, 2, 3, 4]\n",
190+
"[1, 2, 2, 3, 4]\n",
191+
"[1, 2, 2, 3, 4]\n"
192+
]
193+
}
194+
],
195+
"source": [
196+
"### Return Function\n",
197+
"\n",
198+
"def sortF(l):\n",
199+
" for i in range(len(l)):\n",
200+
" minx=i\n",
201+
" for j in range(i+1,len(l)):\n",
202+
" if(l[j]<l[minx]):\n",
203+
" minx=j\n",
204+
" l[minx], l[i]=l[i], l[minx]\n",
205+
" return l\n",
206+
"l=[]\n",
207+
"for i in range(5):\n",
208+
" l.append(int(input()))\n",
209+
"print(l)\n",
210+
"p=sortF(l)\n",
211+
"o=l\n",
212+
"print(l)\n",
213+
"print(p)\n",
214+
"print(o)"
215+
]
174216
},
175217
{
176218
"cell_type": "code",
177-
"execution_count": null,
219+
"execution_count": 1,
178220
"metadata": {},
179-
"outputs": [],
180-
"source": []
221+
"outputs": [
222+
{
223+
"name": "stdin",
224+
"output_type": "stream",
225+
"text": [
226+
" 1\n",
227+
" 3\n",
228+
" 5\n",
229+
" 2\n",
230+
" 1\n"
231+
]
232+
},
233+
{
234+
"name": "stdout",
235+
"output_type": "stream",
236+
"text": [
237+
"[1, 3, 5, 2, 1]\n"
238+
]
239+
}
240+
],
241+
"source": [
242+
"### MAP Function\n",
243+
"\n",
244+
"def sortF(l):\n",
245+
" for i in range(len(l)):\n",
246+
" minx=i\n",
247+
" for j in range(i+1,len(l)):\n",
248+
" if(l[j]<l[minx]):\n",
249+
" minx=j\n",
250+
" l[minx], l[i]=l[i], l[minx]\n",
251+
" return l\n",
252+
"l=[]\n",
253+
"for i in range(5):\n",
254+
" l.append(int(input()))\n",
255+
"print(l)\n",
256+
"p=map(sortF,l)"
257+
]
181258
}
182259
],
183260
"metadata": {

0 commit comments

Comments
 (0)