From f79ac488225df6df21019c3167f76a2f75a95132 Mon Sep 17 00:00:00 2001 From: Dmitrii Ushakov Date: Sun, 22 Mar 2026 23:47:29 +0300 Subject: [PATCH 1/2] Bringing the limits, solution, examples and asserts into conformity with the description --- tasks/easy/collections/partiphify.toml | 41 ++++++++++++-------------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/tasks/easy/collections/partiphify.toml b/tasks/easy/collections/partiphify.toml index 79efafa..6b43a63 100644 --- a/tasks/easy/collections/partiphify.toml +++ b/tasks/easy/collections/partiphify.toml @@ -17,30 +17,27 @@ description_ru = """ limits = """ - $1 \\leq |\\text{numbers}| \\leq 100$ -- $1 \\leq \\text{parts} \\leq |\\text{numbers}|$ +- $1 \\leq \\text{parts} \\leq 100$ - $-100 \\leq \\text{numbers}[i] \\leq 100$ """ solution = """ def solution(numbers: list, parts: int) -> list: - import math - - if not numbers: - return [] - - part_size = math.ceil(len(numbers) / parts) + length = len(numbers) + part_size, big_parts = divmod(length, parts) + small_parts = parts - big_parts result = [] - - for i in range(0, len(numbers), part_size): - part = numbers[i:i + part_size] - if part: - result.append(part) - + for i in range(big_parts): + result.append(numbers[:part_size+1]) + numbers = numbers[part_size+1:] + for i in range(small_parts): + result.append(numbers[:part_size]) + numbers = numbers[part_size:] return result """ examples = """ -solution([1], 2) == [[1]] +solution([1], 2) == [[1], []] solution([1, 2, 3], 3) == [[1], [2], [3]] solution([1, 2, 3, 4, 5], 2) == [[1, 2, 3], [4, 5]] """ @@ -67,7 +64,7 @@ name = "integer" [[asserts]] arguments = [[1], 2] comment = "One element two parts" -expected = [[1]] +expected = [[1], []] [[asserts]] arguments = [[1, 2, 3], 3] @@ -92,7 +89,7 @@ expected = [[1, 2], [3, 4], [5, 6]] [[asserts]] arguments = [[1, 2, 3, 4, 5, 6, 7], 3] comment = "Seven into three" -expected = [[1, 2, 3], [4, 5, 6], [7]] +expected = [[1, 2, 3], [4, 5], [6, 7]] [[asserts]] arguments = [[1, 2], 1] @@ -117,7 +114,7 @@ expected = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] [[asserts]] arguments = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 3] comment = "Ten into three" -expected = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10]] +expected = [[1, 2, 3, 4], [5, 6, 7], [8, 9, 10]] [[asserts]] arguments = [[1], 1] @@ -142,7 +139,7 @@ expected = [[1, 2, 3, 4], [5, 6, 7]] [[asserts]] arguments = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 4] comment = "Ten into four" -expected = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]] +expected = [[1, 2, 3], [4, 5, 6], [7, 8], [9, 10]] [[asserts]] arguments = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], 3] @@ -171,8 +168,8 @@ expected = [[1, 2], [3, 4], [5]] [[asserts]] arguments = [[1, 2, 3, 4, 5, 6, 7, 8, 9], 4] -comment = "Nine into four (ceil gives 3 parts)" -expected = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] +comment = "Nine into four" +expected = [[1, 2, 3], [4, 5], [6, 7], [8, 9]] [[asserts]] arguments = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 5] @@ -182,12 +179,12 @@ expected = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]] [[asserts]] arguments = [[1, 2, 3, 4], 3] comment = "Four into three" -expected = [[1, 2], [3, 4]] +expected = [[1, 2], [3], [4]] [[asserts]] arguments = [[1, 2, 3, 4, 5, 6], 4] comment = "Six into four" -expected = [[1, 2], [3, 4], [5, 6]] +expected = [[1, 2], [3, 4], [5], [6]] [[asserts]] arguments = [[1, 2, 3, 4, 5, 6, 7], 4] From 843e17d53f846fe61bda6f935940ef084c058b40 Mon Sep 17 00:00:00 2001 From: Dmitrii Ushakov Date: Sun, 22 Mar 2026 23:52:07 +0300 Subject: [PATCH 2/2] Adding extra asserts --- tasks/easy/collections/partiphify.toml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tasks/easy/collections/partiphify.toml b/tasks/easy/collections/partiphify.toml index 6b43a63..18bfab6 100644 --- a/tasks/easy/collections/partiphify.toml +++ b/tasks/easy/collections/partiphify.toml @@ -210,3 +210,18 @@ expected = [[1], [2]] arguments = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 2] comment = "Ten into two" expected = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10]] + +[[asserts]] +arguments = [[1, 2, 3, 4, 5, 6, 7, 8, 9], 7] +comment = "Nine into seven" +expected = [[1, 2], [3, 4], [5], [6], [7], [8], [9]] + +[[asserts]] +arguments = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], 5] +comment = "Eleven into five" +expected = [[1, 2, 3], [4, 5], [6, 7], [8, 9], [10, 11]] + +[[asserts]] +arguments = [[1, 2], 5] +comment = "Two into five" +expected = [[1], [2], [], [], []]