From b49c77c19f436e65a39015c2d8a8df87647faa2b Mon Sep 17 00:00:00 2001 From: Heba Shaheen Date: Mon, 30 Dec 2024 23:06:33 +0300 Subject: [PATCH 01/20] remove_duplicates function --- solutions/remove_duplicates.py | 40 +++++++++++++++++++++++ solutions/tests/test_remove_duplicates.py | 0 2 files changed, 40 insertions(+) create mode 100644 solutions/remove_duplicates.py create mode 100644 solutions/tests/test_remove_duplicates.py diff --git a/solutions/remove_duplicates.py b/solutions/remove_duplicates.py new file mode 100644 index 000000000..3b72fd373 --- /dev/null +++ b/solutions/remove_duplicates.py @@ -0,0 +1,40 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +""" +A Function for removing the duplicates items in a list. + +Created on 2024-12-30 +Author: Heba Shaheen +""" + + +def remove_duplicates(nums: list) -> list: + """ + Given a list, return a new list without any repeated values. + The function goes item by item; if an item is not in the result list, + it appends it; otherwise, it skips it. + + Args: + nums (list): The list from which duplicates will be removed. + + Returns: + list: A list without duplicates. + Raises: + AssertionError: If the input not a list. + + >>> remove_duplicates([2, 4, 2, 5, 5, 7, 2, 6]) + [2, 4, 5, 7, 6] + + >>> remove_duplicates(["a", "v", "e", "e", "q", "v", "q", "a"]) + ['a', 'v', 'e', 'q'] + + >>> remove_duplicates(["Heba", "Noor", "Heba", "Noor"]) + ['Heba', 'Noor'] + """ + assert isinstance(nums, list), "The input should be a list" + result = [] # List to store the result without duplicates + + for num in nums: + if num not in result: + result.append(num) # Add the number to the result list + return result diff --git a/solutions/tests/test_remove_duplicates.py b/solutions/tests/test_remove_duplicates.py new file mode 100644 index 000000000..e69de29bb From f4ec29230aaf0d0a20364a2b5bba31b5a83ed1b9 Mon Sep 17 00:00:00 2001 From: Heba Shaheen Date: Mon, 30 Dec 2024 23:22:33 +0300 Subject: [PATCH 02/20] test file --- solutions/tests/test_remove_duplicates.py | 48 +++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/solutions/tests/test_remove_duplicates.py b/solutions/tests/test_remove_duplicates.py index e69de29bb..05abcdb33 100644 --- a/solutions/tests/test_remove_duplicates.py +++ b/solutions/tests/test_remove_duplicates.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +""" +Test module for remove_duplicates function. + +Created on 2024-12-30 +Author: Heba Shaheen +""" + +import unittest + +from ..remove_duplicates import remove_duplicates + + +class TestCountBetween(unittest.TestCase): + """Test remove_duplicates function""" + + # Standard test cases + def test_numbers_list(self): + """It should remove duplicates numbers""" + self.assertEqual(remove_duplicates([1, 2, 3, 2, 3, 4]), [1, 2, 3, 4]) + + def test_letters_list(self): + """It should remove duplicates letters""" + self.assertEqual( + remove_duplicates(["a", "v", "e", "e", "q"]), ["a", "v", "e", "q"] + ) + + def test_mix_list(self): + """It should remove duplicates items""" + self.assertEqual( + remove_duplicates([1, 2, 3, "e", 2, 1, "e", 5, "a"]), [1, 2, 3, "e", 5, "a"] + ) + + # Edge cases + def test_empty_list(self): + """It should return empty list""" + self.assertEqual(remove_duplicates([]), []) + + # Defensive tests + def test_invalid_type(self): + """It should raise AssertionError if numbers is not a list""" + with self.assertRaises(AssertionError): + remove_duplicates("1, 2, 2") + + +if __name__ == "__main__": + unittest.main() From f99c170e641ed7388055b9e510e0239811b33fbe Mon Sep 17 00:00:00 2001 From: Heba Shaheen Date: Mon, 30 Dec 2024 23:25:07 +0300 Subject: [PATCH 03/20] change code --- solutions/tests/test_remove_duplicates.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solutions/tests/test_remove_duplicates.py b/solutions/tests/test_remove_duplicates.py index 05abcdb33..33bcd99e4 100644 --- a/solutions/tests/test_remove_duplicates.py +++ b/solutions/tests/test_remove_duplicates.py @@ -12,7 +12,7 @@ from ..remove_duplicates import remove_duplicates -class TestCountBetween(unittest.TestCase): +class TestRemoveDuplicates(unittest.TestCase): """Test remove_duplicates function""" # Standard test cases From 7fafebf501948ffcdf1c7832cd57ec5955fec369 Mon Sep 17 00:00:00 2001 From: Heba Shaheen Date: Mon, 30 Dec 2024 23:42:38 +0300 Subject: [PATCH 04/20] create __init__ file --- solutions/__init__.py | 0 solutions/tests/__init__.py | 0 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 solutions/__init__.py create mode 100644 solutions/tests/__init__.py diff --git a/solutions/__init__.py b/solutions/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/solutions/tests/__init__.py b/solutions/tests/__init__.py new file mode 100644 index 000000000..e69de29bb From ad84209e8d6e1b668d7362513d865a17a8ae003f Mon Sep 17 00:00:00 2001 From: raghad598 Date: Tue, 31 Dec 2024 17:19:06 +0200 Subject: [PATCH 05/20] function for counting words and unit test done --- count words.py | 18 ++++++++++++++++++ unit test.py | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 count words.py create mode 100644 unit test.py diff --git a/count words.py b/count words.py new file mode 100644 index 000000000..78d5aff76 --- /dev/null +++ b/count words.py @@ -0,0 +1,18 @@ +def count_words(text): + """ + Counts the number of words in a given string. + + Args: + text (str): The string to analyze. + + Returns: + int: The number of words in the string. + """ + # Split the text by whitespace and count the resulting parts + words = text.split() + return len(words) + +# Example usage +example_text = "Hello, Nova! How many words are in this sentence?" +word_count = count_words(example_text) +print(f"The text contains {word_count} words.") diff --git a/unit test.py b/unit test.py new file mode 100644 index 000000000..4fea2c415 --- /dev/null +++ b/unit test.py @@ -0,0 +1,42 @@ +import unittest + +def count_words(text): + """ + Counts the number of words in a given string. + + Args: + text (str): The string to analyze. + + Returns: + int: The number of words in the string. + """ + words = text.split() + return len(words) + +class TestCountWords(unittest.TestCase): + def test_empty_string(self): + """Test with an empty string""" + self.assertEqual(count_words(""), 0) + + def test_single_word(self): + """Test with a single word""" + self.assertEqual(count_words("hello"), 1) + + def test_multiple_words(self): + """Test with multiple words""" + self.assertEqual(count_words("Hello, world!"), 2) + + def test_extra_spaces(self): + """Test with extra spaces""" + self.assertEqual(count_words(" Hello world "), 2) + + def test_numbers_and_words(self): + """Test with a mix of numbers and words""" + self.assertEqual(count_words("123 hello 456 world"), 4) + + def test_special_characters(self): + """Test with special characters""" + self.assertEqual(count_words("!@# $%^ &*()"), 3) + +if __name__ == "__main__": + unittest.main() \ No newline at end of file From 33b19bae8217a130f7b7408f437d9aba87bd6b8d Mon Sep 17 00:00:00 2001 From: "s.ashour82" Date: Tue, 31 Dec 2024 20:21:08 +0200 Subject: [PATCH 06/20] is_palindrome function coding is_palindrome function and its unit test --- solutions/is_palindrome.py | 40 ++++++++++++++++++ solutions/tests/test_is_palindrome.py | 60 +++++++++++++++++++++++++++ 2 files changed, 100 insertions(+) create mode 100644 solutions/is_palindrome.py create mode 100644 solutions/tests/test_is_palindrome.py diff --git a/solutions/is_palindrome.py b/solutions/is_palindrome.py new file mode 100644 index 000000000..797da018d --- /dev/null +++ b/solutions/is_palindrome.py @@ -0,0 +1,40 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +""" +A module for checking if a given string is a palindrome (reads the same backward as forward) + +Module contents: + - palindrome: input string is palindrome if it reads the same backward as forward + +Created on XX XX XX +@author: Saad M. Ashour +""" + + +def is_palindrome(s: str) -> bool: + """ + Check if a given string is a palindrome. + + A palindrome is a word, phrase, number, or other sequence of characters + that reads the same forward and backward, ignoring spaces, punctuation, + and case sensitivity. + + Parameters: + s (str): The input string to be checked. + + Returns: + bool: True if the input string is a palindrome, False otherwise. + + Examples: + >>> is_palindrome("A man, a plan, a canal, Panama") + True + >>> is_palindrome("hello") + False + >>> is_palindrome("Madam") + True + """ + # Remove non-alphanumeric characters and convert to lowercase + cleaned = "".join(char.lower() for char in s if char.isalnum()) + + # Check if the cleaned string is equal to its reverse + return cleaned == cleaned[::-1] diff --git a/solutions/tests/test_is_palindrome.py b/solutions/tests/test_is_palindrome.py new file mode 100644 index 000000000..f6d746a61 --- /dev/null +++ b/solutions/tests/test_is_palindrome.py @@ -0,0 +1,60 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +""" +Unit tests for is_palindrome function. + +@author: Saad M. Ashour +""" + +import unittest + +from ..is_palindrome import is_palindrome + + +class TestIsPalindrome(unittest.TestCase): + """ + Unit tests for the is_palindrome function. + + These tests check various cases to ensure that the is_palindrome function correctly + identifies palindromes, considering case insensitivity, non-alphanumeric characters, + and other edge cases. + """ + + def test_palindrome(self): + """ + Test cases where the string is a palindrome. + """ + self.assertTrue(is_palindrome("A man, a plan, a canal, Panama")) + self.assertTrue(is_palindrome("racecar")) + self.assertTrue(is_palindrome("Madam")) + + def test_non_palindrome(self): + """ + Test cases where the string is not a palindrome. + """ + self.assertFalse(is_palindrome("hello")) + self.assertFalse(is_palindrome("world")) + + def test_empty_string(self): + """ + Test case where the input is an empty string, which is considered a palindrome. + """ + self.assertTrue(is_palindrome("")) + + def test_single_character(self): + """ + Test case where the input is a single character, which is always a palindrome. + """ + self.assertTrue(is_palindrome("a")) + self.assertTrue(is_palindrome("1")) + + def test_only_non_alphanumeric(self): + """ + Test case where the input contains only non-alphanumeric characters. + The function should ignore them and return True for empty string. + """ + self.assertTrue(is_palindrome("!@#$$@!")) + + +if __name__ == "__main__": + unittest.main() From 11329c75d3d242d73ccf38d5d283a957cadd43f1 Mon Sep 17 00:00:00 2001 From: Heba Shaheen Date: Wed, 1 Jan 2025 19:34:06 +0300 Subject: [PATCH 07/20] decimal to binary challenge --- solutions/decimal_to_binary.py | 41 +++++++++++++++++++ solutions/tests/test_decimal_to_binary.py | 49 +++++++++++++++++++++++ 2 files changed, 90 insertions(+) create mode 100644 solutions/decimal_to_binary.py create mode 100644 solutions/tests/test_decimal_to_binary.py diff --git a/solutions/decimal_to_binary.py b/solutions/decimal_to_binary.py new file mode 100644 index 000000000..b8a74ecac --- /dev/null +++ b/solutions/decimal_to_binary.py @@ -0,0 +1,41 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +""" +A function to convert decimal numbers to binary. + +Created on 1/1/2025 +@author: Heba Shaheen +""" + + +def decimal_to_binary(n: int) -> str: + """Give the binary number for a decimal + + Args: + n (int): Decimal number to be converted + + Returns: + str: Binary representation of the decimal number + + Raises: + AssertionError: if the input is not an integer + + >>> decimal_to_binary(10) + "1010" + + >>> decimal_to_binary(20) + "10100" + + >>> decimal_to_binary(255) + "11111111" + """ + # Handle the edge case for 0 + assert isinstance(n, int), "The input should be integer" + assert n >= 0, "Give a positive input" + if n == 0: + return "0" + binary = "" + while n > 0: + binary = str(n % 2) + binary + n //= 2 + return binary diff --git a/solutions/tests/test_decimal_to_binary.py b/solutions/tests/test_decimal_to_binary.py new file mode 100644 index 000000000..cab9b4c46 --- /dev/null +++ b/solutions/tests/test_decimal_to_binary.py @@ -0,0 +1,49 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +""" +Unit tests for decimal_to_binary function. + +@author: Heba Shaheen +""" + +import unittest + +from ..decimal_to_binary import decimal_to_binary + + +class TestBinary(unittest.TestCase): + """Unit tests for decimal_to_binary function.""" + + def test_number_0(self): + """It should give the binary""" + actual = decimal_to_binary(0) + expected = "0" + self.assertEqual(actual, expected) + + def test_number_2(self): + """It should give the binary""" + actual = decimal_to_binary(2) + expected = "10" + self.assertEqual(actual, expected) + + def test_number_5(self): + """It should give the binary""" + actual = decimal_to_binary(5) + expected = "101" + self.assertEqual(actual, expected) + + def test_number_15(self): + """It should give the binary""" + actual = decimal_to_binary(15) + expected = "1111" + self.assertEqual(actual, expected) + + def test_non_integer_input(self): + """It should raise an assertion error if the argument is not an integer""" + with self.assertRaises(AssertionError): + decimal_to_binary("1") + + def test_non_negative_input(self): + """It should raise an assertion error if the argument is negative""" + with self.assertRaises(AssertionError): + decimal_to_binary(-3) From e3775f5ec7d5ff21d5c52cc877b01c55fd2917ff Mon Sep 17 00:00:00 2001 From: Raghad Abdul Rahim Date: Thu, 2 Jan 2025 13:52:26 +0300 Subject: [PATCH 08/20] Update count words.py --- count words.py | 41 +++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/count words.py b/count words.py index 78d5aff76..c2ef107ca 100644 --- a/count words.py +++ b/count words.py @@ -1,18 +1,35 @@ -def count_words(text): - """ - Counts the number of words in a given string. +""" +A module for counting words in a string. + +Module contents: + - count_words: counts the number of words in a string. + +Created on 01 01 2025 +@author: Raghad +""" + + +def count_words(text: str) -> int: + """Count the number of words in a given string. - Args: - text (str): The string to analyze. + Parameters: + text: str, the input string to analyze - Returns: - int: The number of words in the string. + Returns -> int: number of words in the text + + Raises: + AssertionError: if the argument is not a string + + >>> count_words("Hello World") + 2 + >>> count_words("Python programming is fun") + 4 + >>> count_words("") + 0 """ + # Validate input + assert isinstance(text, str), "Input must be a string" + # Split the text by whitespace and count the resulting parts words = text.split() return len(words) - -# Example usage -example_text = "Hello, Nova! How many words are in this sentence?" -word_count = count_words(example_text) -print(f"The text contains {word_count} words.") From caf684758a9c3d6ec8e79dac44cbce1f7d0643cd Mon Sep 17 00:00:00 2001 From: Raghad Abdul Rahim Date: Thu, 2 Jan 2025 13:53:12 +0300 Subject: [PATCH 09/20] Rename unit test.py to test_count_words.py --- unit test.py => test_count_words.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename unit test.py => test_count_words.py (98%) diff --git a/unit test.py b/test_count_words.py similarity index 98% rename from unit test.py rename to test_count_words.py index 4fea2c415..491a4d1ad 100644 --- a/unit test.py +++ b/test_count_words.py @@ -39,4 +39,4 @@ def test_special_characters(self): self.assertEqual(count_words("!@# $%^ &*()"), 3) if __name__ == "__main__": - unittest.main() \ No newline at end of file + unittest.main() From fb077d02b1cc457be166d0a40df2e41c4667a09d Mon Sep 17 00:00:00 2001 From: Raghad Abdul Rahim Date: Thu, 2 Jan 2025 13:53:24 +0300 Subject: [PATCH 10/20] Rename count words.py to count_words.py --- count words.py => count_words.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename count words.py => count_words.py (100%) diff --git a/count words.py b/count_words.py similarity index 100% rename from count words.py rename to count_words.py From 4d00190f7aae2a7df27f5d179f73c14bac9b6ebd Mon Sep 17 00:00:00 2001 From: Raghad Abdul Rahim Date: Thu, 2 Jan 2025 14:02:29 +0300 Subject: [PATCH 11/20] Create count_words.py --- solutions/count_words.py | 1 + 1 file changed, 1 insertion(+) create mode 100644 solutions/count_words.py diff --git a/solutions/count_words.py b/solutions/count_words.py new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/solutions/count_words.py @@ -0,0 +1 @@ + From 3471944eb3fe3165a9fbcb092518c1fab252ccb5 Mon Sep 17 00:00:00 2001 From: Raghad Abdul Rahim Date: Thu, 2 Jan 2025 14:02:54 +0300 Subject: [PATCH 12/20] Update count_words.py --- solutions/count_words.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/solutions/count_words.py b/solutions/count_words.py index 8b1378917..c2ef107ca 100644 --- a/solutions/count_words.py +++ b/solutions/count_words.py @@ -1 +1,35 @@ +""" +A module for counting words in a string. +Module contents: + - count_words: counts the number of words in a string. + +Created on 01 01 2025 +@author: Raghad +""" + + +def count_words(text: str) -> int: + """Count the number of words in a given string. + + Parameters: + text: str, the input string to analyze + + Returns -> int: number of words in the text + + Raises: + AssertionError: if the argument is not a string + + >>> count_words("Hello World") + 2 + >>> count_words("Python programming is fun") + 4 + >>> count_words("") + 0 + """ + # Validate input + assert isinstance(text, str), "Input must be a string" + + # Split the text by whitespace and count the resulting parts + words = text.split() + return len(words) From ebe48d0230ee9425c2269ad97e5396e1bb41104c Mon Sep 17 00:00:00 2001 From: Raghad Abdul Rahim Date: Thu, 2 Jan 2025 14:03:10 +0300 Subject: [PATCH 13/20] Delete count_words.py --- count_words.py | 35 ----------------------------------- 1 file changed, 35 deletions(-) delete mode 100644 count_words.py diff --git a/count_words.py b/count_words.py deleted file mode 100644 index c2ef107ca..000000000 --- a/count_words.py +++ /dev/null @@ -1,35 +0,0 @@ -""" -A module for counting words in a string. - -Module contents: - - count_words: counts the number of words in a string. - -Created on 01 01 2025 -@author: Raghad -""" - - -def count_words(text: str) -> int: - """Count the number of words in a given string. - - Parameters: - text: str, the input string to analyze - - Returns -> int: number of words in the text - - Raises: - AssertionError: if the argument is not a string - - >>> count_words("Hello World") - 2 - >>> count_words("Python programming is fun") - 4 - >>> count_words("") - 0 - """ - # Validate input - assert isinstance(text, str), "Input must be a string" - - # Split the text by whitespace and count the resulting parts - words = text.split() - return len(words) From d3c1950e5c9f621b346b859951b99e8dbb28014b Mon Sep 17 00:00:00 2001 From: Raghad Abdul Rahim Date: Thu, 2 Jan 2025 14:04:34 +0300 Subject: [PATCH 14/20] Create test_count_words --- solutions/tests/test_count_words | 46 ++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 solutions/tests/test_count_words diff --git a/solutions/tests/test_count_words b/solutions/tests/test_count_words new file mode 100644 index 000000000..2e201cfaf --- /dev/null +++ b/solutions/tests/test_count_words @@ -0,0 +1,46 @@ +import unittest +from solutions.count_words import count_words + + +def count_words(text): + """ + Counts the number of words in a given string. + + Args: + text (str): The string to analyze. + + Returns: + int: The number of words in the string. + """ + words = text.split() + return len(words) + + +class TestCountWords(unittest.TestCase): + def test_empty_string(self): + """Test with an empty string""" + self.assertEqual(count_words(""), 0) + + def test_single_word(self): + """Test with a single word""" + self.assertEqual(count_words("hello"), 1) + + def test_multiple_words(self): + """Test with multiple words""" + self.assertEqual(count_words("Hello, world!"), 2) + + def test_extra_spaces(self): + """Test with extra spaces""" + self.assertEqual(count_words(" Hello world "), 2) + + def test_numbers_and_words(self): + """Test with a mix of numbers and words""" + self.assertEqual(count_words("123 hello 456 world"), 4) + + def test_special_characters(self): + """Test with special characters""" + self.assertEqual(count_words("!@# $%^ &*()"), 3) + + +if __name__ == "__main__": + unittest.main() From bda59e41b5a916260a968a787cda11e0df30d2a6 Mon Sep 17 00:00:00 2001 From: Raghad Abdul Rahim Date: Thu, 2 Jan 2025 14:04:53 +0300 Subject: [PATCH 15/20] Delete test_count_words.py --- test_count_words.py | 42 ------------------------------------------ 1 file changed, 42 deletions(-) delete mode 100644 test_count_words.py diff --git a/test_count_words.py b/test_count_words.py deleted file mode 100644 index 491a4d1ad..000000000 --- a/test_count_words.py +++ /dev/null @@ -1,42 +0,0 @@ -import unittest - -def count_words(text): - """ - Counts the number of words in a given string. - - Args: - text (str): The string to analyze. - - Returns: - int: The number of words in the string. - """ - words = text.split() - return len(words) - -class TestCountWords(unittest.TestCase): - def test_empty_string(self): - """Test with an empty string""" - self.assertEqual(count_words(""), 0) - - def test_single_word(self): - """Test with a single word""" - self.assertEqual(count_words("hello"), 1) - - def test_multiple_words(self): - """Test with multiple words""" - self.assertEqual(count_words("Hello, world!"), 2) - - def test_extra_spaces(self): - """Test with extra spaces""" - self.assertEqual(count_words(" Hello world "), 2) - - def test_numbers_and_words(self): - """Test with a mix of numbers and words""" - self.assertEqual(count_words("123 hello 456 world"), 4) - - def test_special_characters(self): - """Test with special characters""" - self.assertEqual(count_words("!@# $%^ &*()"), 3) - -if __name__ == "__main__": - unittest.main() From dbbbfd9512d770eab5733e55b70d7b71ac049e85 Mon Sep 17 00:00:00 2001 From: "s.ashour82" Date: Wed, 8 Jan 2025 09:02:01 +0200 Subject: [PATCH 16/20] update is_palindrome Falaq notes were updated.. --- solutions/is_palindrome.py | 11 +++++++---- solutions/tests/test_is_palindrome.py | 19 ++++++++++--------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/solutions/is_palindrome.py b/solutions/is_palindrome.py index 797da018d..61ee8e2de 100644 --- a/solutions/is_palindrome.py +++ b/solutions/is_palindrome.py @@ -6,12 +6,12 @@ Module contents: - palindrome: input string is palindrome if it reads the same backward as forward -Created on XX XX XX +Created on 30.12.2024 @author: Saad M. Ashour """ -def is_palindrome(s: str) -> bool: +def is_palindrome(input_string: str) -> bool: """ Check if a given string is a palindrome. @@ -20,7 +20,7 @@ def is_palindrome(s: str) -> bool: and case sensitivity. Parameters: - s (str): The input string to be checked. + input_string (str): The input string to be checked. Returns: bool: True if the input string is a palindrome, False otherwise. @@ -33,8 +33,11 @@ def is_palindrome(s: str) -> bool: >>> is_palindrome("Madam") True """ + # AssertionError: Input must be a string + assert isinstance(input_string, str), "Input must be a string" + # Remove non-alphanumeric characters and convert to lowercase - cleaned = "".join(char.lower() for char in s if char.isalnum()) + cleaned = "".join(char.lower() for char in input_string if char.isalnum()) # Check if the cleaned string is equal to its reverse return cleaned == cleaned[::-1] diff --git a/solutions/tests/test_is_palindrome.py b/solutions/tests/test_is_palindrome.py index f6d746a61..1f1c8d4b8 100644 --- a/solutions/tests/test_is_palindrome.py +++ b/solutions/tests/test_is_palindrome.py @@ -24,36 +24,37 @@ def test_palindrome(self): """ Test cases where the string is a palindrome. """ - self.assertTrue(is_palindrome("A man, a plan, a canal, Panama")) - self.assertTrue(is_palindrome("racecar")) - self.assertTrue(is_palindrome("Madam")) + actual = is_palindrome("A man, a plan, a canal, Panama") + self.assertTrue(actual) def test_non_palindrome(self): """ Test cases where the string is not a palindrome. """ - self.assertFalse(is_palindrome("hello")) - self.assertFalse(is_palindrome("world")) + actual = is_palindrome("hello") + self.assertFalse(actual) def test_empty_string(self): """ Test case where the input is an empty string, which is considered a palindrome. """ - self.assertTrue(is_palindrome("")) + actual = is_palindrome("") + self.assertTrue(actual) def test_single_character(self): """ Test case where the input is a single character, which is always a palindrome. """ - self.assertTrue(is_palindrome("a")) - self.assertTrue(is_palindrome("1")) + actual = is_palindrome("a") + self.assertTrue(actual) def test_only_non_alphanumeric(self): """ Test case where the input contains only non-alphanumeric characters. The function should ignore them and return True for empty string. """ - self.assertTrue(is_palindrome("!@#$$@!")) + actual = is_palindrome("!@#$$@!") + self.assertTrue(actual) if __name__ == "__main__": From cc479c18aedd4766a3b4884a449998b89055b4b6 Mon Sep 17 00:00:00 2001 From: "s.ashour82" Date: Wed, 8 Jan 2025 10:06:56 +0200 Subject: [PATCH 17/20] Update retrospective.md Retrospective md file created from starch --- collaboration/retrospective.md | 56 ++++++++++++++++++++++++++++++++-- 1 file changed, 54 insertions(+), 2 deletions(-) diff --git a/collaboration/retrospective.md b/collaboration/retrospective.md index 74e18813b..8b0930e22 100644 --- a/collaboration/retrospective.md +++ b/collaboration/retrospective.md @@ -1,23 +1,75 @@ -# Retrospective +# Retrospective: Group 18 - Collaborative Work Activity ## Stop Doing +- **Inefficient Coordination:** Stop relying on informal communication + methods that cause misunderstandings or delays. + +- **Overloading Tasks:** Avoid taking on excessive responsibilities + without proper delegation or prioritization. + +- **Passive Participation:** Stop being a silent participant in discussions; + ensure to actively contribute to conversations. + ## Continue Doing +- **Effective Teamwork:** Continue fostering collaboration by sharing ideas + openly and respecting diverse perspectives. + +- **Timely Updates:** Maintain a habit of providing timely progress updates + to keep the team aligned. + +- **Using Tools:** Keep leveraging collaborative tools + (e.g., shared documents, project management software) to enhance productivity. + ## Start Doing +- **Structured Planning:** Begin creating more detailed action plans with + clear milestones and deadlines. + +- **Feedback Loops:** Start implementing regular feedback sessions to + evaluate progress and address challenges early. + +- **Skill Development:** Focus on improving specific skills related + to collaborative work and presentation to contribute more effectively. + ## Lessons Learned +- Effective communication is crucial to avoid duplication of efforts and ensure alignment. + +- Clear roles and responsibilities significantly enhance team productivity. + +- Flexibility in strategy allows for better adaptation to unforeseen challenges. + +- Regular check-ins help maintain momentum and ensure accountability. + ______________________________________________________________________ ## Strategy vs. Board ### What parts of your plan went as expected? +- Collaboration tools were effectively utilized to + share resources and coordinate tasks. + +- The team successfully met initial deadlines for project deliverables. + +- Team members demonstrated a willingness to support each other when challenges arose. + ### What parts of your plan did not work out? +- Some tasks were delayed due to unclear task ownership. + +- Miscommunication led to redundant efforts in certain areas. + +- Time zone differences caused occasional scheduling conflicts. + ### Did you need to add things that weren't in your strategy? -### Or remove extra steps? +- Yes, we added weekly synchronization meetings to + address miscommunications and ensure alignment. + +- Included additional training sessions for team members to + improve tool usage efficiency. From 0b76d7816a51b4eb55af7486f0eceaed89a6a53b Mon Sep 17 00:00:00 2001 From: "s.ashour82" Date: Wed, 8 Jan 2025 10:11:17 +0200 Subject: [PATCH 18/20] Delete retrospective.md remove this file --- collaboration/retrospective.md | 75 ---------------------------------- 1 file changed, 75 deletions(-) delete mode 100644 collaboration/retrospective.md diff --git a/collaboration/retrospective.md b/collaboration/retrospective.md deleted file mode 100644 index 8b0930e22..000000000 --- a/collaboration/retrospective.md +++ /dev/null @@ -1,75 +0,0 @@ - - -# Retrospective: Group 18 - Collaborative Work Activity - -## Stop Doing - -- **Inefficient Coordination:** Stop relying on informal communication - methods that cause misunderstandings or delays. - -- **Overloading Tasks:** Avoid taking on excessive responsibilities - without proper delegation or prioritization. - -- **Passive Participation:** Stop being a silent participant in discussions; - ensure to actively contribute to conversations. - -## Continue Doing - -- **Effective Teamwork:** Continue fostering collaboration by sharing ideas - openly and respecting diverse perspectives. - -- **Timely Updates:** Maintain a habit of providing timely progress updates - to keep the team aligned. - -- **Using Tools:** Keep leveraging collaborative tools - (e.g., shared documents, project management software) to enhance productivity. - -## Start Doing - -- **Structured Planning:** Begin creating more detailed action plans with - clear milestones and deadlines. - -- **Feedback Loops:** Start implementing regular feedback sessions to - evaluate progress and address challenges early. - -- **Skill Development:** Focus on improving specific skills related - to collaborative work and presentation to contribute more effectively. - -## Lessons Learned - -- Effective communication is crucial to avoid duplication of efforts and ensure alignment. - -- Clear roles and responsibilities significantly enhance team productivity. - -- Flexibility in strategy allows for better adaptation to unforeseen challenges. - -- Regular check-ins help maintain momentum and ensure accountability. - -______________________________________________________________________ - -## Strategy vs. Board - -### What parts of your plan went as expected? - -- Collaboration tools were effectively utilized to - share resources and coordinate tasks. - -- The team successfully met initial deadlines for project deliverables. - -- Team members demonstrated a willingness to support each other when challenges arose. - -### What parts of your plan did not work out? - -- Some tasks were delayed due to unclear task ownership. - -- Miscommunication led to redundant efforts in certain areas. - -- Time zone differences caused occasional scheduling conflicts. - -### Did you need to add things that weren't in your strategy? - -- Yes, we added weekly synchronization meetings to - address miscommunications and ensure alignment. - -- Included additional training sessions for team members to - improve tool usage efficiency. From 5970adf6a8ffe7d07fab8ae6f0f0544adefa5428 Mon Sep 17 00:00:00 2001 From: Raghad Abdul Rahim Date: Wed, 8 Jan 2025 11:37:42 +0300 Subject: [PATCH 19/20] Update test_count_words --- solutions/tests/test_count_words | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/solutions/tests/test_count_words b/solutions/tests/test_count_words index 2e201cfaf..1429ea00c 100644 --- a/solutions/tests/test_count_words +++ b/solutions/tests/test_count_words @@ -1,19 +1,15 @@ -import unittest -from solutions.count_words import count_words - +""" +A module for testing count_words.py -def count_words(text): - """ - Counts the number of words in a given string. +Module contents: + - Unit Test cases for function count_words - Args: - text (str): The string to analyze. +Created on 01 01 2025 +@author: Raghad +""" - Returns: - int: The number of words in the string. - """ - words = text.split() - return len(words) +import unittest +from solutions.count_words import count_words class TestCountWords(unittest.TestCase): From c0ddc514dd97d65a7dae12e1e9bc5e9040085cf5 Mon Sep 17 00:00:00 2001 From: Heba Shaheen Date: Wed, 8 Jan 2025 13:23:28 +0300 Subject: [PATCH 20/20] make changes --- solutions/decimal_to_binary.py | 16 ++++++++-------- solutions/tests/test_decimal_to_binary.py | 12 ++++++------ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/solutions/decimal_to_binary.py b/solutions/decimal_to_binary.py index b8a74ecac..ba2f9e08e 100644 --- a/solutions/decimal_to_binary.py +++ b/solutions/decimal_to_binary.py @@ -8,11 +8,11 @@ """ -def decimal_to_binary(n: int) -> str: +def decimal_to_binary(decimal_input: int) -> str: """Give the binary number for a decimal Args: - n (int): Decimal number to be converted + decimal_input (int): Decimal number to be converted Returns: str: Binary representation of the decimal number @@ -30,12 +30,12 @@ def decimal_to_binary(n: int) -> str: "11111111" """ # Handle the edge case for 0 - assert isinstance(n, int), "The input should be integer" - assert n >= 0, "Give a positive input" - if n == 0: + assert isinstance(decimal_input, int), "The input should be integer" + assert decimal_input >= 0, "Give a positive input" + if decimal_input == 0: return "0" binary = "" - while n > 0: - binary = str(n % 2) + binary - n //= 2 + while decimal_input > 0: + binary = str(decimal_input % 2) + binary + decimal_input //= 2 return binary diff --git a/solutions/tests/test_decimal_to_binary.py b/solutions/tests/test_decimal_to_binary.py index cab9b4c46..a2635e9b6 100644 --- a/solutions/tests/test_decimal_to_binary.py +++ b/solutions/tests/test_decimal_to_binary.py @@ -11,29 +11,29 @@ from ..decimal_to_binary import decimal_to_binary -class TestBinary(unittest.TestCase): +class TestDecimalToBinary(unittest.TestCase): """Unit tests for decimal_to_binary function.""" def test_number_0(self): - """It should give the binary""" + """It should return "0" as binary""" actual = decimal_to_binary(0) expected = "0" self.assertEqual(actual, expected) def test_number_2(self): - """It should give the binary""" + """It should return "10" as binary""" actual = decimal_to_binary(2) expected = "10" self.assertEqual(actual, expected) def test_number_5(self): - """It should give the binary""" + """It should return "101" as binary""" actual = decimal_to_binary(5) expected = "101" self.assertEqual(actual, expected) def test_number_15(self): - """It should give the binary""" + """It should return "1111" as binary""" actual = decimal_to_binary(15) expected = "1111" self.assertEqual(actual, expected) @@ -43,7 +43,7 @@ def test_non_integer_input(self): with self.assertRaises(AssertionError): decimal_to_binary("1") - def test_non_negative_input(self): + def test_negative_input(self): """It should raise an assertion error if the argument is negative""" with self.assertRaises(AssertionError): decimal_to_binary(-3)