From f60ad5f12cf917fe921f83caf4e7f73f1fea9ba8 Mon Sep 17 00:00:00 2001 From: Nadiia Miziukanova Date: Fri, 17 Jul 2026 15:33:45 +0300 Subject: [PATCH 1/3] Solution --- app/test_split_integer.py | 53 +++++++++++++++++++++++++++++++++++---- 1 file changed, 48 insertions(+), 5 deletions(-) diff --git a/app/test_split_integer.py b/app/test_split_integer.py index ef3aa668a..f4fba2659 100644 --- a/app/test_split_integer.py +++ b/app/test_split_integer.py @@ -2,20 +2,63 @@ def test_sum_of_the_parts_should_be_equal_to_value() -> None: - pass + value, num_of_parts = 17, 4 + assert ( + split_integer(value, num_of_parts) == [4, 4, 4, 5], + "Sum of the parts should be equal to value" + ) def test_should_split_into_equal_parts_when_value_divisible_by_parts() -> None: - pass + value, num_of_parts = 36, 6 + assert ( + split_integer(value, num_of_parts) == [6, 6, 6, 6, 6, 6], + "Value divisible by parts should be split into equal parts" + ) def test_should_return_part_equals_to_value_when_split_into_one_part() -> None: - pass + value, num_of_parts = 8, 1 + assert ( + split_integer(value, num_of_parts) == [8], + "Return part equals to value when split into one part" + ) def test_parts_should_be_sorted_when_they_are_not_equal() -> None: - pass + value, num_of_parts = 32, 6 + assert ( + split_integer(value, num_of_parts) == [5, 5, 5, 5, 6, 6], + "Parts sorted when they are not equal" + ) def test_should_add_zeros_when_value_is_less_than_number_of_parts() -> None: - pass + value, num_of_parts = 1, 2 + assert( + split_integer(value, num_of_parts) == [0, 1], + "Adding zeros when value is less than number of parts" + ) + + +# result: +# split_integer(8, 1) == [8] +# split_integer(6, 2) == [3, 3] +# split_integer(17, 4) == [4, 4, 4, 5] +# split_integer(32, 6) == [5, 5, 5, 5, 6, 6] + +# Write tests for split_integer function that takes 2 positive integers value and number_of_parts and returns an array containing exactly number_of_parts integer elements: + +# the difference between the max and min number in the array should be <= 1; +# the array should be sorted ascending (from lowest to highest). +# Please note: you have to use pytest for writing tests. + +# You don't need to validate arguments (they are always valid). + +# Notes: + +# write tests in the /app/test_split_integer.py module; +# their names indicate what exactly they should test. +# Run pytest app/ to check if function pass your tests. + +# Run pytest --numprocesses=auto tests/ to check if your tests cover all boundary conditions and pass task tests. \ No newline at end of file From 6277b470359e6c033c7caefe25b8063a130418c3 Mon Sep 17 00:00:00 2001 From: Nadiia Miziukanova Date: Fri, 17 Jul 2026 15:39:15 +0300 Subject: [PATCH 2/3] Solution 2.0 --- app/test_split_integer.py | 48 ++++----------------------------------- 1 file changed, 5 insertions(+), 43 deletions(-) diff --git a/app/test_split_integer.py b/app/test_split_integer.py index f4fba2659..e992db90b 100644 --- a/app/test_split_integer.py +++ b/app/test_split_integer.py @@ -3,62 +3,24 @@ def test_sum_of_the_parts_should_be_equal_to_value() -> None: value, num_of_parts = 17, 4 - assert ( - split_integer(value, num_of_parts) == [4, 4, 4, 5], - "Sum of the parts should be equal to value" - ) + assert split_integer(value, num_of_parts) == [4, 4, 4, 5] def test_should_split_into_equal_parts_when_value_divisible_by_parts() -> None: value, num_of_parts = 36, 6 - assert ( - split_integer(value, num_of_parts) == [6, 6, 6, 6, 6, 6], - "Value divisible by parts should be split into equal parts" - ) + assert split_integer(value, num_of_parts) == [6, 6, 6, 6, 6, 6] def test_should_return_part_equals_to_value_when_split_into_one_part() -> None: value, num_of_parts = 8, 1 - assert ( - split_integer(value, num_of_parts) == [8], - "Return part equals to value when split into one part" - ) + assert split_integer(value, num_of_parts) == [8] def test_parts_should_be_sorted_when_they_are_not_equal() -> None: value, num_of_parts = 32, 6 - assert ( - split_integer(value, num_of_parts) == [5, 5, 5, 5, 6, 6], - "Parts sorted when they are not equal" - ) + assert split_integer(value, num_of_parts) == [5, 5, 5, 5, 6, 6] def test_should_add_zeros_when_value_is_less_than_number_of_parts() -> None: value, num_of_parts = 1, 2 - assert( - split_integer(value, num_of_parts) == [0, 1], - "Adding zeros when value is less than number of parts" - ) - - -# result: -# split_integer(8, 1) == [8] -# split_integer(6, 2) == [3, 3] -# split_integer(17, 4) == [4, 4, 4, 5] -# split_integer(32, 6) == [5, 5, 5, 5, 6, 6] - -# Write tests for split_integer function that takes 2 positive integers value and number_of_parts and returns an array containing exactly number_of_parts integer elements: - -# the difference between the max and min number in the array should be <= 1; -# the array should be sorted ascending (from lowest to highest). -# Please note: you have to use pytest for writing tests. - -# You don't need to validate arguments (they are always valid). - -# Notes: - -# write tests in the /app/test_split_integer.py module; -# their names indicate what exactly they should test. -# Run pytest app/ to check if function pass your tests. - -# Run pytest --numprocesses=auto tests/ to check if your tests cover all boundary conditions and pass task tests. \ No newline at end of file + assert split_integer(value, num_of_parts) == [0, 1] From 569af6740f32678fb5f1840681f44db2cb738269 Mon Sep 17 00:00:00 2001 From: Nadiia Miziukanova Date: Fri, 17 Jul 2026 15:42:38 +0300 Subject: [PATCH 3/3] Solution 3.0 --- app/test_split_integer.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/app/test_split_integer.py b/app/test_split_integer.py index e992db90b..2e4935df4 100644 --- a/app/test_split_integer.py +++ b/app/test_split_integer.py @@ -2,25 +2,20 @@ def test_sum_of_the_parts_should_be_equal_to_value() -> None: - value, num_of_parts = 17, 4 - assert split_integer(value, num_of_parts) == [4, 4, 4, 5] + assert split_integer(17, 4) == [4, 4, 4, 5] def test_should_split_into_equal_parts_when_value_divisible_by_parts() -> None: - value, num_of_parts = 36, 6 - assert split_integer(value, num_of_parts) == [6, 6, 6, 6, 6, 6] + assert split_integer(36, 6) == [6, 6, 6, 6, 6, 6] def test_should_return_part_equals_to_value_when_split_into_one_part() -> None: - value, num_of_parts = 8, 1 - assert split_integer(value, num_of_parts) == [8] + assert split_integer(8, 1) == [8] def test_parts_should_be_sorted_when_they_are_not_equal() -> None: - value, num_of_parts = 32, 6 - assert split_integer(value, num_of_parts) == [5, 5, 5, 5, 6, 6] + assert split_integer(32, 6) == [5, 5, 5, 5, 6, 6] def test_should_add_zeros_when_value_is_less_than_number_of_parts() -> None: - value, num_of_parts = 1, 2 - assert split_integer(value, num_of_parts) == [0, 1] + assert split_integer(1, 2) == [0, 1]