Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions MERGE_SUMMARY.md
Original file line number Diff line number Diff line change
@@ -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
Binary file modified src/__pycache__/string_reversal.cpython-312.pyc
Binary file not shown.
Binary file modified src/__pycache__/string_utils.cpython-312.pyc
Binary file not shown.
14 changes: 8 additions & 6 deletions src/string_reversal.py
Original file line number Diff line number Diff line change
@@ -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().

Expand All @@ -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)
Binary file not shown.
Binary file modified tests/__pycache__/test_string_utils.cpython-312-pytest-8.3.5.pyc
Binary file not shown.
13 changes: 10 additions & 3 deletions tests/test_string_reversal.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down