```python
import time
import random
from typing import List
import sympy
import math
import string
import types
```


```python
sympy.init_printing()
```


```python
def quick_sort(collection: list) -> list:
    if len(collection) < 2:
        return collection
    pivot = collection.pop()
    greater: List[int] = []
    lesser: List[int] = []

    for element in collection:
        (greater if element > pivot else lesser).append(element)
    return quick_sort(lesser) + [pivot] + quick_sort(greater)
```


```python
user_input = input("input numbers seperated by a comma:\n").strip()
unsorted = user_input.split(',')
print(quick_sort(unsorted))
```

    ['']



```python
unsorted = random.shuffle(list(range(1000000)), None)
```


```python
n = sympy.Symbol('n')
expr = sympy.solve(8 * sympy.functions.log(n, 2) - n)
expr
```


```python
expr[0].evalf()
```


```python
f_1 = 8 * sympy.functions.ln(n)
f_2 = n
sympy.plot(f_1, f_2, (n,0.1,100))
```


```python
f_1 = (n**2 * 100)
f_2 = (2**n)
p = sympy.plot(f_1, f_2, (n,0,100), show=False, legend=True)
p[0].label = '$100 * n**2$'
p[0].line_color = 'red'
p[1].label = '$2**n$'
p.show()
```


```python
f_1 = sympy.log(n)
f_2 = sympy.sqrt(n)
f_3 = n
f_4 = n * sympy.log(n)
f_5 = n**2
f_6 = n**3
f_7 = 2**n
f_8 = sympy.factorial(n)
```


```python
t0 = 1000 # 1000 milliseconds
```


```python
r_1 = sympy.solve(f_1 - t0)
r_2 = sympy.solve(f_2 - t0)
r_3 = sympy.solve(f_3 - t0)
r_4 = sympy.solve(f_4 - t0)
r_5 = sympy.solve(f_5 - t0)
r_6 = sympy.solve(f_6 - t0)
r_7 = sympy.solve(f_7 - t0)
```


```python
r_8 = sympy.solve(f_8 - t0)
```


```python
print(r_1, r_2, r_3, r_4, r_5, r_6, r_7)
```

    [exp(1000)] [1000000] [1000] [exp(LambertW(1000))] [-10*sqrt(10), 10*sqrt(10)] [10, -5 - 5*sqrt(3)*I, -5 + 5*sqrt(3)*I] [log(10**(3/log(2)))]



```python
# c_01 = random.sample(range(-100, 100), 10)
c_01 = random.choices(string.ascii_letters + string.digits, k=10)

print(c_01)

for i, item in enumerate(c_01):
    for j in range(i)[::-1]:
        if item < c_01[j]:
            c_01[j+1] = c_01[j]
            c_01[j] = item
        else:
            break
print(c_01)
```

    ['M', 'X', 'L', '8', 'D', 'i', 'g', 'S', 'b', 'N']
    ['8', 'D', 'L', 'M', 'N', 'S', 'X', 'b', 'g', 'i']



```python
A = random.sample(range(-100, 100), 10)
print(A)
# A = random.choices(string.ascii_letters + string.digits, k=10)

for j, key in enumerate(A):
    if j == 0:
        pass
    i = j - 1
    while i > 0 and A[i] > key:
        A[i+1] = A[i]
        i = i - 1
    A[i+1] = key

print(A)
```


```python
def fib(n: int) -> int:
    if n <= 0: return 0
    if n == 1 | n == 2: return 1
    prev = curr= 1
    for i in range(3, n+1):
        sum = prev + curr
        prev = curr
        curr = sum
    return curr
```


```python

fib(4)
```




    3




```python
def fib_recursive(n: int) -> int:
    if n <= 2: return 1
    return fib_recursive(n-1) + fib_recursive(n-2)
```


```python
fib_recursive(6)
```




    8




```python
def coinChange(coins: List[int], amount: int) -> int:
    # 数组大小为 amount，初始值为 n，对于每个 amount，最多需要 amount 个 1 分的 coin。
    results = list(range(amount+1))
    for i, r in enumerate(results): # 从 0 开始计算最小 amount
        if i == 0: continue # start from amount == 1
        for coin in coins:
            remains = r - coin
            if remains < 0: continue
            results[i] = min(r, 1 + results[remains - coin])
    return results[amount]

```


```python
for amount in range(12):
    print("{}, {}".format(amount, coinChange([1,2,5], amount)))
```

    0, 0
    1, 1
    2, 2
    3, 3
    4, 1
    5, 2
    6, 4
    7, 5
    8, 5
    9, 5
    10, 1
    11, 2



```python
def coinChange(coins: List[int], amount: int) -> int:
    if amount < 0: return -1
    dp = list(range(amount+1))
    for i in range(amount+1):
        result = []
        for coin in coins:
```

da8f40a3234b70ecef2933f0f68610534c60b054
ipynb
Jupyter Notebook
sorts/my_algo.ipynb
wuchenchen/Python
301ccb57d6ce5fc1d0edff40260464152da5bbc7
MIT
2021-08-25T13:29:58.000Z
2021-08-25T13:29:58.000Z
sorts/my_algo.ipynb
wuchenchen/Python
301ccb57d6ce5fc1d0edff40260464152da5bbc7
MIT
sorts/my_algo.ipynb
wuchenchen/Python
301ccb57d6ce5fc1d0edff40260464152da5bbc7
MIT
Qwen/Qwen-72B
1. YES
2. YES