import math
import random
from typing import Callable

def square(x: int) -> int:
    return x * x

def cube(x: int) -> int:
    return x ** 3

def fourth(x: int) -> int:
    return int(math.pow(x, 4))

au_carre = square
print(au_carre(2))

all_functions = [square, cube, fourth]
for f in all_functions:
    print(f(5))

def apply_twice(f: Callable[[int], int], x: int) -> int:
    return f(f(x))

print(apply_twice(cube, 2))

def twice(f: Callable[[int], int]) -> Callable[[int], int]:
    def f_of_f(x: int) -> int:
        return f(f(x))
    return f_of_f

fourth_power = twice(square)
print(fourth_power(2))

plus_4 = twice(lambda x: x+2)
print(plus_4(8))

ma_liste = list(range(10))
random.shuffle(ma_liste)
print(ma_liste)
liste_triee = sorted(ma_liste, key = lambda x: -x)
print(liste_triee)