|
23 | 23 | }, |
24 | 24 | { |
25 | 25 | "cell_type": "code", |
26 | | - "execution_count": 4, |
| 26 | + "execution_count": 1, |
27 | 27 | "metadata": {}, |
28 | 28 | "outputs": [ |
29 | 29 | { |
30 | 30 | "name": "stdout", |
31 | 31 | "output_type": "stream", |
32 | 32 | "text": [ |
33 | | - "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9] [0, 0, 1, 0, 1, 0, 0]\n" |
| 33 | + "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9] [1, 2, 2, 2, 0, 0, 0]\n" |
34 | 34 | ] |
35 | 35 | } |
36 | 36 | ], |
|
50 | 50 | }, |
51 | 51 | { |
52 | 52 | "cell_type": "code", |
53 | | - "execution_count": 6, |
| 53 | + "execution_count": 2, |
54 | 54 | "metadata": {}, |
55 | 55 | "outputs": [ |
56 | 56 | { |
|
68 | 68 | " 'False']" |
69 | 69 | ] |
70 | 70 | }, |
71 | | - "execution_count": 6, |
| 71 | + "execution_count": 2, |
72 | 72 | "metadata": {}, |
73 | 73 | "output_type": "execute_result" |
74 | 74 | } |
|
93 | 93 | }, |
94 | 94 | { |
95 | 95 | "cell_type": "code", |
96 | | - "execution_count": 7, |
| 96 | + "execution_count": 3, |
97 | 97 | "metadata": {}, |
98 | 98 | "outputs": [ |
99 | 99 | { |
|
102 | 102 | "[0, 2, 4, 6, 8]" |
103 | 103 | ] |
104 | 104 | }, |
105 | | - "execution_count": 7, |
| 105 | + "execution_count": 3, |
106 | 106 | "metadata": {}, |
107 | 107 | "output_type": "execute_result" |
108 | 108 | } |
|
120 | 120 | }, |
121 | 121 | { |
122 | 122 | "cell_type": "code", |
123 | | - "execution_count": 15, |
124 | | - "metadata": { |
125 | | - "collapsed": true |
126 | | - }, |
| 123 | + "execution_count": 4, |
| 124 | + "metadata": {}, |
127 | 125 | "outputs": [], |
128 | 126 | "source": [ |
129 | 127 | "from collections import Counter\n", |
|
132 | 130 | }, |
133 | 131 | { |
134 | 132 | "cell_type": "code", |
135 | | - "execution_count": 22, |
| 133 | + "execution_count": 5, |
136 | 134 | "metadata": {}, |
137 | 135 | "outputs": [ |
138 | 136 | { |
139 | 137 | "data": { |
140 | 138 | "text/plain": [ |
141 | | - "Counter({0: 3, 1: 2, 2: 2})" |
| 139 | + "Counter({1: 1, 2: 3, 0: 3})" |
142 | 140 | ] |
143 | 141 | }, |
144 | | - "execution_count": 22, |
| 142 | + "execution_count": 5, |
145 | 143 | "metadata": {}, |
146 | 144 | "output_type": "execute_result" |
147 | 145 | } |
|
162 | 160 | }, |
163 | 161 | { |
164 | 162 | "cell_type": "code", |
165 | | - "execution_count": 23, |
166 | | - "metadata": { |
167 | | - "collapsed": true |
168 | | - }, |
| 163 | + "execution_count": 6, |
| 164 | + "metadata": {}, |
169 | 165 | "outputs": [], |
170 | 166 | "source": [ |
171 | 167 | "l_long = random.choices(range(5), k=1_000_000)" |
172 | 168 | ] |
173 | 169 | }, |
174 | 170 | { |
175 | 171 | "cell_type": "code", |
176 | | - "execution_count": 24, |
| 172 | + "execution_count": 7, |
177 | 173 | "metadata": {}, |
178 | 174 | "outputs": [ |
179 | 175 | { |
180 | 176 | "name": "stdout", |
181 | 177 | "output_type": "stream", |
182 | 178 | "text": [ |
183 | | - "1.42 s ± 65.6 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n" |
| 179 | + "260 ms ± 33.5 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n" |
184 | 180 | ] |
185 | 181 | } |
186 | 182 | ], |
|
190 | 186 | }, |
191 | 187 | { |
192 | 188 | "cell_type": "code", |
193 | | - "execution_count": 25, |
| 189 | + "execution_count": 8, |
194 | 190 | "metadata": {}, |
195 | 191 | "outputs": [ |
196 | 192 | { |
197 | 193 | "name": "stdout", |
198 | 194 | "output_type": "stream", |
199 | 195 | "text": [ |
200 | | - "1.04 s ± 87.3 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n" |
| 196 | + "283 ms ± 73 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n" |
201 | 197 | ] |
202 | 198 | } |
203 | 199 | ], |
|
224 | 220 | }, |
225 | 221 | { |
226 | 222 | "cell_type": "code", |
227 | | - "execution_count": 16, |
228 | | - "metadata": { |
229 | | - "collapsed": true |
230 | | - }, |
| 223 | + "execution_count": 9, |
| 224 | + "metadata": {}, |
231 | 225 | "outputs": [], |
232 | 226 | "source": [ |
233 | 227 | "from functools import partial" |
234 | 228 | ] |
235 | 229 | }, |
236 | 230 | { |
237 | 231 | "cell_type": "code", |
238 | | - "execution_count": 25, |
239 | | - "metadata": { |
240 | | - "collapsed": true |
241 | | - }, |
| 232 | + "execution_count": 10, |
| 233 | + "metadata": {}, |
242 | 234 | "outputs": [], |
243 | 235 | "source": [ |
244 | 236 | "def line_function(x, slope, intercept):\n", |
|
247 | 239 | }, |
248 | 240 | { |
249 | 241 | "cell_type": "code", |
250 | | - "execution_count": 26, |
251 | | - "metadata": { |
252 | | - "collapsed": true |
253 | | - }, |
| 242 | + "execution_count": 11, |
| 243 | + "metadata": {}, |
254 | 244 | "outputs": [], |
255 | 245 | "source": [ |
256 | 246 | "line1 = partial(line_function, slope=2.0, intercept=3.0)" |
257 | 247 | ] |
258 | 248 | }, |
259 | 249 | { |
260 | 250 | "cell_type": "code", |
261 | | - "execution_count": 27, |
| 251 | + "execution_count": 12, |
262 | 252 | "metadata": {}, |
263 | 253 | "outputs": [ |
264 | 254 | { |
|
267 | 257 | "(3.0, 5.0)" |
268 | 258 | ] |
269 | 259 | }, |
270 | | - "execution_count": 27, |
| 260 | + "execution_count": 12, |
271 | 261 | "metadata": {}, |
272 | 262 | "output_type": "execute_result" |
273 | 263 | } |
|
285 | 275 | }, |
286 | 276 | { |
287 | 277 | "cell_type": "code", |
288 | | - "execution_count": 28, |
289 | | - "metadata": { |
290 | | - "collapsed": true |
291 | | - }, |
| 278 | + "execution_count": 13, |
| 279 | + "metadata": {}, |
292 | 280 | "outputs": [], |
293 | 281 | "source": [ |
294 | 282 | "def create_line(slope, intercept):\n", |
|
299 | 287 | }, |
300 | 288 | { |
301 | 289 | "cell_type": "code", |
302 | | - "execution_count": 29, |
303 | | - "metadata": { |
304 | | - "collapsed": true |
305 | | - }, |
| 290 | + "execution_count": 14, |
| 291 | + "metadata": {}, |
306 | 292 | "outputs": [], |
307 | 293 | "source": [ |
308 | 294 | "line2 = create_line(2.0, 3.0)" |
309 | 295 | ] |
310 | 296 | }, |
311 | 297 | { |
312 | 298 | "cell_type": "code", |
313 | | - "execution_count": 30, |
| 299 | + "execution_count": 15, |
314 | 300 | "metadata": {}, |
315 | 301 | "outputs": [ |
316 | 302 | { |
|
319 | 305 | "(3.0, 5.0)" |
320 | 306 | ] |
321 | 307 | }, |
322 | | - "execution_count": 30, |
| 308 | + "execution_count": 15, |
323 | 309 | "metadata": {}, |
324 | 310 | "output_type": "execute_result" |
325 | 311 | } |
|
351 | 337 | }, |
352 | 338 | { |
353 | 339 | "cell_type": "code", |
354 | | - "execution_count": 1, |
355 | | - "metadata": { |
356 | | - "collapsed": true |
357 | | - }, |
| 340 | + "execution_count": 16, |
| 341 | + "metadata": {}, |
358 | 342 | "outputs": [], |
359 | 343 | "source": [ |
360 | 344 | "def create_elevator(highest_floor):\n", |
|
376 | 360 | }, |
377 | 361 | { |
378 | 362 | "cell_type": "code", |
379 | | - "execution_count": 2, |
380 | | - "metadata": { |
381 | | - "collapsed": true |
382 | | - }, |
| 363 | + "execution_count": 17, |
| 364 | + "metadata": {}, |
383 | 365 | "outputs": [], |
384 | 366 | "source": [ |
385 | 367 | "my_elevator = create_elevator(2)" |
386 | 368 | ] |
387 | 369 | }, |
388 | 370 | { |
389 | 371 | "cell_type": "code", |
390 | | - "execution_count": 5, |
| 372 | + "execution_count": 18, |
391 | 373 | "metadata": {}, |
392 | 374 | "outputs": [ |
393 | 375 | { |
394 | 376 | "name": "stdout", |
395 | 377 | "output_type": "stream", |
396 | 378 | "text": [ |
397 | | - "press 0: current floor: 0\n", |
| 379 | + "no such floor: -1\n", |
| 380 | + "press -1: current floor: 0\n", |
398 | 381 | "press 1: current floor: 1\n", |
399 | 382 | "press 2: current floor: 2\n", |
400 | 383 | "no such floor: 3\n", |
401 | 384 | "press 3: current floor: 2\n", |
402 | | - "no such floor: -1\n", |
403 | | - "press -1: current floor: 2\n", |
404 | | - "no such floor: -1\n", |
405 | | - "press -1: current floor: 2\n", |
| 385 | + "press 2: current floor: 2\n", |
| 386 | + "press 0: current floor: 0\n", |
| 387 | + "no such floor: 3\n", |
| 388 | + "press 3: current floor: 0\n", |
406 | 389 | "press 1: current floor: 1\n", |
407 | 390 | "press 1: current floor: 1\n", |
408 | | - "no such floor: 3\n", |
409 | | - "press 3: current floor: 1\n", |
410 | | - "press 1: current floor: 1\n" |
| 391 | + "no such floor: -1\n", |
| 392 | + "press -1: current floor: 1\n" |
411 | 393 | ] |
412 | 394 | } |
413 | 395 | ], |
|
433 | 415 | "name": "python", |
434 | 416 | "nbconvert_exporter": "python", |
435 | 417 | "pygments_lexer": "ipython3", |
436 | | - "version": "3.6.2" |
| 418 | + "version": "3.7.5" |
437 | 419 | } |
438 | 420 | }, |
439 | 421 | "nbformat": 4, |
440 | | - "nbformat_minor": 2 |
| 422 | + "nbformat_minor": 4 |
441 | 423 | } |
0 commit comments