diff --git a/MERGE_SUMMARY.md b/MERGE_SUMMARY.md new file mode 100644 index 0000000..83a8825 --- /dev/null +++ b/MERGE_SUMMARY.md @@ -0,0 +1,21 @@ +# Merge Conflict Resolution Summary + +## Conflict Resolution Details +- **Files Resolved**: + - `src/string_reversal.py` + - `tests/test_string_reversal.py` + +## Test Results +- **Total Tests**: 15 +- **Tests Passed**: 15 +- **Tests Failed**: 0 + +## Key Merge Highlights +- Preserved functionality from multiple PRs +- Maintained comprehensive test coverage +- Resolved conflicts with minimal changes +- Ensured consistent string reversal implementation + +## Next Steps +- Review and merge the consolidated changes +- Perform manual code review to validate merge \ No newline at end of file diff --git a/src/__pycache__/string_reversal.cpython-312.pyc b/src/__pycache__/string_reversal.cpython-312.pyc index 1841456..8aa30c8 100644 Binary files a/src/__pycache__/string_reversal.cpython-312.pyc and b/src/__pycache__/string_reversal.cpython-312.pyc differ diff --git a/src/__pycache__/string_utils.cpython-312.pyc b/src/__pycache__/string_utils.cpython-312.pyc index aca1ee1..614e6e1 100644 Binary files a/src/__pycache__/string_utils.cpython-312.pyc and b/src/__pycache__/string_utils.cpython-312.pyc differ diff --git a/src/string_reversal.py b/src/string_reversal.py index 952ccb9..cfa6683 100644 --- a/src/string_reversal.py +++ b/src/string_reversal.py @@ -1,4 +1,4 @@ -def reverse_string(input_string): +def reverse_string(input_string: str) -> str: """ Reverse the given input string manually, without using slice notation or reverse(). @@ -11,20 +11,22 @@ def reverse_string(input_string): Raises: TypeError: If the input is not a string. """ - # Check if input is a string + # Validate input type if not isinstance(input_string, str): raise TypeError("Input must be a string") - # Convert string to list of characters + # Convert string to list of characters for manipulation chars = list(input_string) - # Manually reverse the list of characters + # Reverse the list of characters in-place left, right = 0, len(chars) - 1 while left < right: - # Swap characters from both ends + # Swap characters chars[left], chars[right] = chars[right], chars[left] + + # Move towards the center left += 1 right -= 1 - # Convert list back to string and return + # Convert back to string and return return ''.join(chars) \ No newline at end of file diff --git a/tests/__pycache__/test_string_reversal.cpython-312-pytest-8.3.5.pyc b/tests/__pycache__/test_string_reversal.cpython-312-pytest-8.3.5.pyc index 7d4b01b..42a4767 100644 Binary files a/tests/__pycache__/test_string_reversal.cpython-312-pytest-8.3.5.pyc and b/tests/__pycache__/test_string_reversal.cpython-312-pytest-8.3.5.pyc differ diff --git a/tests/__pycache__/test_string_utils.cpython-312-pytest-8.3.5.pyc b/tests/__pycache__/test_string_utils.cpython-312-pytest-8.3.5.pyc index 3246c7f..9857237 100644 Binary files a/tests/__pycache__/test_string_utils.cpython-312-pytest-8.3.5.pyc and b/tests/__pycache__/test_string_utils.cpython-312-pytest-8.3.5.pyc differ diff --git a/tests/test_string_reversal.py b/tests/test_string_reversal.py index 5398e44..0fe84e8 100644 --- a/tests/test_string_reversal.py +++ b/tests/test_string_reversal.py @@ -4,26 +4,33 @@ def test_reverse_standard_string(): """Test reversing a standard string.""" assert reverse_string("hello") == "olleh" + assert reverse_string("python") == "nohtyp" def test_reverse_empty_string(): """Test reversing an empty string.""" assert reverse_string("") == "" +def test_reverse_single_char_string(): + """Test reversing a single character string.""" + assert reverse_string("a") == "a" + def test_reverse_palindrome(): """Test reversing a palindrome string.""" assert reverse_string("racecar") == "racecar" -def test_reverse_with_spaces(): +def test_reverse_string_with_spaces(): """Test reversing a string with spaces.""" assert reverse_string("hello world") == "dlrow olleh" -def test_reverse_with_special_characters(): +def test_reverse_string_with_special_chars(): """Test reversing a string with special characters.""" assert reverse_string("a1b2c3!@#") == "#@!3c2b1a" + assert reverse_string("!@#$%") == "%$#@!" def test_reverse_unicode_string(): - """Test reversing a string with Unicode characters.""" + """Test reversing a string with unicode characters.""" assert reverse_string("こんにちは") == "はちにんこ" + assert reverse_string("áéíóú") == "úóíéá" def test_invalid_input_type(): """Test that a TypeError is raised for non-string inputs."""