From 0b4ce9ac35546e7afda3bcbb02b1eb03472df425 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B9=20=D0=91=D0=B0?= =?UTF-8?q?=D0=B3=D0=B8=D0=BD?= Date: Fri, 8 May 2026 17:16:59 +0000 Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20README.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/README.md b/README.md index 5aad3ea..23da5f7 100644 --- a/README.md +++ b/README.md @@ -77,3 +77,28 @@ - praktika03/heart_disease_results.csv +ввоооооооооооооооооооот +def run_length_encode(s: str) -> list: + if not s: + return [] + + result = [] + current_char = s[0] + count = 1 + + for char in s[1:]: + if char == current_char: + count += 1 + else: + result.append((current_char, count)) + current_char = char + count = 1 + + result.append((current_char, count)) + return result + + +# Тесты +assert run_length_encode("aaabbc") == [("a", 3), ("b", 2), ("c", 1)] +assert run_length_encode("abc") == [("a", 1), ("b", 1), ("c", 1)] +assert run_length_encode("") == [] \ No newline at end of file