diff --git a/solutions/missing_numbers.py b/solutions/missing_numbers.py deleted file mode 100644 index 9e3173d95..000000000 --- a/solutions/missing_numbers.py +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- -""" -A module that returns a sorted list of all the missing numbers in a string containing integers separated by spaces. - -Module contents: - - missing_numbers: creates a list with all the missing integers. - -Created on 06/01/2025 -@author: Amin -""" - - -def missing_numbers(nums_string: str) -> list: - """Find the missing numbers in a list of integers. - - Parameters: - nums_string: string, the input string containing the integers to be checked - - Returns -> list: the list of the missing integers in the input string - Raises: - AssertionError: if the argument is not a list of integers - >>> missing_numbers("0 1") - [] - >>> missing_numbers("0 2 3") - [1] - >>> missing_numbers("0 4") - [1, 2, 3] - >>> missing_numbers("3 1 7") - [2, 4, 5, 6] - """ - assert isinstance( - nums_string, str - ), "input must be a string containing integers separated by spaces" - # Transform the original numbers string into a list by splitting it - nums_list = nums_string.split() - nums = [] - # Transform each element of the list from str into an integer - for i in nums_list: - try: - num = int(i) - nums.append(num) - - except: - return "The input contains non-integer values" - miss = [] - # Identify the maximal number in the list - maximum = nums[0] - for i in nums: - if i > maximum: - maximum = i - # Identify the minimal number in the list - minimum = nums[0] - for i in nums: - if i < minimum: - minimum = i - for num in range(minimum + 1, maximum): - if num not in nums: - miss.append(num) - return miss diff --git a/solutions/tests/test_missing_numbers.py b/solutions/tests/test_missing_numbers.py deleted file mode 100644 index 79bb50c91..000000000 --- a/solutions/tests/test_missing_numbers.py +++ /dev/null @@ -1,63 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- -""" -A module for testing the missing_numbers function. - -Test cases include: - - strings with missing numbers. - - strings without missing numbers. - - strings containing letters or other non-numerical characters. - - strings containing number formats other than integers. - - strings containing different spacing sizes. - - Sorted and unsorted numbers. - - Edge cases: empty strings, single-number strings. - - Invalid inputs: non-string values (e.g., integers or floats). - -Created on 06/01/2025 -@author: Amin -""" - -import unittest - -from ..missing_numbers import missing_numbers - - -class TestMissingNumbers(unittest.TestCase): - """Test the missing_number function""" - - def test_unsorted_string(self): - """It should return a sorted list with all the missing numbers""" - self.assertEqual(missing_numbers("3 0"), [1, 2]) - - def test_no_missing_number(self): - """It should return [] for lists without missing numbers""" - self.assertEqual(missing_numbers("1 2"), []) - - def test_one_missing_number(self): - """It should return a list containing only the missing number""" - self.assertEqual(missing_numbers("0 2"), [1]) - - def test_multiple_cases(self): - """It should return a sorted list with all the missing numbers""" - self.assertEqual(missing_numbers("1 4"), [2, 3]) - - def test_different_spaces(self): - """It should function properly regardless of how many spaces are there in the initial string""" - self.assertEqual(missing_numbers("1 4"), [2, 3]) - - def test_not_string(self): - """It should raise AssertionError for non-string input""" - with self.assertRaises(AssertionError): - missing_numbers(123) - - def test_not_numbers(self): - """It should return a message for strings containing letters or other non-numerical characters""" - self.assertEqual( - missing_numbers("1 g"), ("The input contains non-integer values") - ) - - def test_non_integer_numbers(self): - """It should return a message for strings containing number formats other than integers""" - self.assertEqual( - missing_numbers("1 2.1"), ("The input contains non-integer values") - )