From 649de7b871fed3fd6f40dea185e776b9eff8cc8b Mon Sep 17 00:00:00 2001 From: daviddoji Date: Sun, 10 May 2026 18:58:03 +0200 Subject: [PATCH] Bandera tricolor en Python --- src/Python/003.py | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 src/Python/003.py 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