update insertion_sort

This commit is contained in:
Rohit Tanwar
2018-02-20 17:08:10 +05:30
parent 9e7878b00d
commit 7cc78ca4c4
28 changed files with 1252 additions and 1222 deletions

View File

@ -1,19 +1,19 @@
### chunk
Chunks an array into smaller lists of a specified size.
Uses `range` to create a list of desired size. Then use `map` on this list and fill it with splices of `arr`.
```python
from math import ceil
def chunk(arr, size):
return list(
map(lambda x: arr[x * size:x * size + size],
list(range(0, ceil(len(arr) / size)))))
```
``` python
chunk([1,2,3,4,5],2) # [[1,2],[3,4],5]
```
### chunk
Chunks an array into smaller lists of a specified size.
Uses `range` to create a list of desired size. Then use `map` on this list and fill it with splices of `arr`.
```python
from math import ceil
def chunk(arr, size):
return list(
map(lambda x: arr[x * size:x * size + size],
list(range(0, ceil(len(arr) / size)))))
```
``` python
chunk([1,2,3,4,5],2) # [[1,2],[3,4],5]
```