Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 31 additions & 46 deletions tasks/easy/strings/more_than_medium.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ tags = ["strings"]
time_to_solve_sec = 350

description_en = """
Given a sentence (as string), return an array of words which are longer than the average length of all the words.
The sentence is given (as a string). Return a list of words that are longer than the average length of all words. If there are no such words, return `["there is no result!"]`.

Words are separated by a whitespace. If there is a trailing period (dot), it should be omitted. If there is no result, return `["there is no result!"]`.
Words are separated by a whitespace. If there are any punctuation marks, they should be omitted (except hyphens).
"""

description_ru = """
Дано предложение (строкой), верните массив слов, длина которых превышает среднюю длину всех слов.
Дано предложение (строкой). Верните список слов, длина которых превышает среднюю длину всех слов. Если таких нет, верните `["there is no result!"]`.

Слова разделены пробелом. Если присутствует точка, её следует пропустить. Если результата нет, верните `["there is no result!"]`.
Слова разделены пробелом. Если присутствуют знаки препинания, их не следует учитывать (кроме дефисов).
"""

limits = """
Expand All @@ -22,7 +22,7 @@ limits = """
solution = """
def solution(sentence: str) -> list:
import re
words = re.findall(r'\\w+', sentence)
words = re.findall(r'[\w-]+', sentence)
if not words:
return ["there is no result!"]

Expand All @@ -33,8 +33,8 @@ def solution(sentence: str) -> list:
"""

examples = """
solution("test") == ["there is no result!"]
solution("This is a sample string") == ["This", "sample", "string"]
solution("hello") == ["there is no result!"]
solution("This is a sample string.") == ["This", "sample", "string"]
solution("Some another sample") == ["another", "sample"]
"""

Expand All @@ -49,13 +49,8 @@ name = "array"
name = "string"

[[asserts]]
arguments = ["test"]
comment = "Single word"
expected = ["there is no result!"]

[[asserts]]
arguments = ["This is a sample string"]
comment = "Multiple words, some longer"
arguments = ["This is a sample string."]
comment = "Multiple words, some longer, the period at the end"
expected = ["This", "sample", "string"]

[[asserts]]
Expand All @@ -79,13 +74,8 @@ comment = "Increasing lengths"
expected = ["ccc", "dddd"]

[[asserts]]
arguments = ["short"]
comment = "Single word short"
expected = ["there is no result!"]

[[asserts]]
arguments = ["one two three four five"]
comment = "Five words"
arguments = ["one, two, three, four, five"]
comment = "Five comma-separated words"
expected = ["three", "four", "five"]

[[asserts]]
Expand All @@ -94,8 +84,8 @@ comment = "Five words with the"
expected = ["quick", "brown", "jumps"]

[[asserts]]
arguments = ["aa bb cc dd ee"]
comment = "All equal length"
arguments = ["aa bb cc DD EE"]
comment = "Five two-letter words"
expected = ["there is no result!"]

[[asserts]]
Expand All @@ -104,33 +94,23 @@ comment = "Four words"
expected = ["python"]

[[asserts]]
arguments = ["test case for this task"]
comment = "Five words equal length"
expected = ["test", "case", "this", "task"]

[[asserts]]
arguments = ["a ab abc abcd"]
comment = "Increasing a sequence"
expected = ["abc", "abcd"]
arguments = ["Some test case for this task..."]
comment = "Six words of approximately equal length, the ellipsis at the end"
expected = ["Some", "test", "case", "this", "task"]

[[asserts]]
arguments = ["short longer longest"]
comment = "Three words increasing"
expected = ["longest"]

[[asserts]]
arguments = ["one"]
comment = "Single word one"
expected = ["there is no result!"]

[[asserts]]
arguments = ["testing code quality"]
comment = "Three words"
expected = ["testing", "quality"]

[[asserts]]
arguments = ["The cat sat on mat"]
comment = "Five words"
arguments = ["The cat sat on mat!"]
comment = "Five words, the exclamation mark at the end"
expected = ["The", "cat", "sat", "mat"]

[[asserts]]
Expand All @@ -139,8 +119,8 @@ comment = "Three words technical"
expected = ["algorithm", "patterns"]

[[asserts]]
arguments = ["a b c d e f g"]
comment = "Seven single letters"
arguments = ["a, b, c, d, e, f, g"]
comment = "Seven comma-separated single letters"
expected = ["there is no result!"]

[[asserts]]
Expand All @@ -155,7 +135,7 @@ expected = ["longerword"]

[[asserts]]
arguments = ["same same same same"]
comment = "All same word"
comment = "All 'same' word"
expected = ["there is no result!"]

[[asserts]]
Expand All @@ -168,11 +148,6 @@ arguments = ["functional programming paradigm"]
comment = "Three long words"
expected = ["functional", "programming"]

[[asserts]]
arguments = ["ab cd ef gh ij"]
comment = "Five two letter words"
expected = ["there is no result!"]

[[asserts]]
arguments = ["machine learning artificial intelligence"]
comment = "Four words AI"
Expand All @@ -192,3 +167,13 @@ expected = ["development", "environment"]
arguments = ["equal equal equal"]
comment = "Three equal words"
expected = ["there is no result!"]

[[asserts]]
arguments = ["This is a well-known fact"]
comment = "A hyphen inside one of the words"
expected = ["well-known"]

[[asserts]]
arguments = ["red-painted T-shirt"]
comment = "A hyphen inside both words"
expected = ["red-painted"]