From f1a37e5ee0d8da01523c25f58fd480645071013b Mon Sep 17 00:00:00 2001 From: Dmitrii <36790425+dimaush@users.noreply.github.com> Date: Sat, 25 Apr 2026 01:04:36 +0300 Subject: [PATCH 1/3] Update longest_winter_holiday.toml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit В одном из примеров ошибка в ответе. --- tasks/medium/collections/longest_winter_holiday.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/medium/collections/longest_winter_holiday.toml b/tasks/medium/collections/longest_winter_holiday.toml index 1de7f84..6140be4 100644 --- a/tasks/medium/collections/longest_winter_holiday.toml +++ b/tasks/medium/collections/longest_winter_holiday.toml @@ -39,7 +39,7 @@ examples = """ solution([1], 0) == 1 solution([0], 1) == 1 solution([1, 0, 1], 1) == 3 -solution([1, 0, 0, 1], 1) == 3 +solution([1, 0, 0, 1], 1) == 2 solution([1, 1, 0, 0, 1, 1], 2) == 6 """ From ccd72a181b7de3396f1f13047a6f6000620ed000 Mon Sep 17 00:00:00 2001 From: Dmitrii Ushakov Date: Fri, 1 May 2026 20:11:58 +0300 Subject: [PATCH 2/3] Fix solution logic and one of the asserts (because there is 'letters' word in the description) --- .../strings/reverse_with_capitalize.toml | 40 +++++++++++-------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/tasks/medium/strings/reverse_with_capitalize.toml b/tasks/medium/strings/reverse_with_capitalize.toml index a55adf4..330c52a 100644 --- a/tasks/medium/strings/reverse_with_capitalize.toml +++ b/tasks/medium/strings/reverse_with_capitalize.toml @@ -17,26 +17,32 @@ limits = """ solution = """ def solution(sentence: str) -> str: - def reverse_word(word): - if not word: - return word - punct = '' - if word[-1] in '.!?': - punct = word[-1] - word = word[:-1] - if not word: - return punct - had_upper = any(char.isupper() for char in word) - reversed_word = word[::-1].lower() - if had_upper: - reversed_word = reversed_word[0].upper() + reversed_word[1:].lower() - return reversed_word + punct - return ' '.join(reverse_word(word) for word in sentence.split()) + sentence += "$" + res = "" + word, upper = [], [] + for ch in sentence: + if ch.isalpha(): + word.append(ch.lower()) + upper.append(ch.isupper()) + elif ch in "'-": + word.append(ch) + else: + word.reverse() + k = 0 + for c in word: + if c.isalpha(): + if upper[k]: + c = c.upper() + k += 1 + res += c + word, upper = [], [] + res += ch + return res[:-1] """ examples = """ solution("Hello! Are you.") == "Olleh! Era uoy." -solution("11Helloworld!") == "Dlrowolleh11!" +solution("11Helloworld!") == "11Dlrowolleh!" solution("Abstraction is often one floor above you.") == "Noitcartsba si netfo eno roolf evoba uoy." """ @@ -56,7 +62,7 @@ expected = "Olleh! Era uoy." [[asserts]] arguments = ["11Helloworld!"] comment = "With numbers and punctuation" -expected = "Dlrowolleh11!" +expected = "11Dlrowolleh!" [[asserts]] arguments = ["Abstraction is often one floor above you."] From 55f84acf9694719f5a40fea3f68c1805f54a767c Mon Sep 17 00:00:00 2001 From: Dmitrii Ushakov Date: Sat, 2 May 2026 16:03:16 +0300 Subject: [PATCH 3/3] Add extra asserts --- tasks/medium/strings/reverse_with_capitalize.toml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tasks/medium/strings/reverse_with_capitalize.toml b/tasks/medium/strings/reverse_with_capitalize.toml index 330c52a..317ed92 100644 --- a/tasks/medium/strings/reverse_with_capitalize.toml +++ b/tasks/medium/strings/reverse_with_capitalize.toml @@ -203,3 +203,18 @@ expected = "Peed Gninrael" arguments = ["Artificial Intelligence"] comment = "AI full term" expected = "Laicifitra Ecnegilletni" + +[[asserts]] +arguments = ["WOW That's Amazing!"] +comment = "An apostrophe inside a word" +expected = "WOW S'taht Gnizama!" + +[[asserts]] +arguments = ["Do you like my T-shirt?"] +comment = "A hyphen inside a word" +expected = "Od uoy ekil ym Trihs-t?" + +[[asserts]] +arguments = ["My BFF lives in Arden-Arcade and works at the AT'n'T shop."] +comment = "Very complicated sentence" +expected = "Ym FFB sevil ni EdacrA-nedra dna skrow ta eht T'N'tA pohs."