diff --git a/src/Python/003.py b/src/Python/003.py new file mode 100644 index 0000000..0ca04a0 --- /dev/null +++ b/src/Python/003.py @@ -0,0 +1,11 @@ +ORDER = ("R", "A", "M") + +def tricolor_flag(lst: list) -> list: + order: dict[str, int] = {value: idx for idx, value in enumerate(ORDER)} + return sorted(lst, key=order.__getitem__) + +check = ["M","R","A","A","R","R","A","M","M"] +print(tricolor_flag(check)) # [R,R,R,A,A,A,M,M,M] + +check = ["M", "R", "A", "R", "R", "A"] +print(tricolor_flag(check)) # [R,R,R,A,A,M] \ No newline at end of file