Skip to content

Implement Manual String Reversal Function without Built-in Methods #31

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: 80a083f4-6cb1-4280-a116-64d177f2347f
Choose a base branch
from

Conversation

momstrosity
Copy link

@momstrosity momstrosity commented May 19, 2025

Implement Manual String Reversal Function without Built-in Methods

Description

Task

Implement String Reversal Function

Acceptance Criteria

  • Function should take a string input and return its reverse
  • Should handle empty strings
  • Should preserve spaces and special characters
  • Should be implemented without using string[::-1] or reverse()

Summary of Work

Overview

This pull request implements a robust string reversal function that meets the following key requirements:

  • Reverses strings manually without using slice notation or built-in reverse methods
  • Handles various input scenarios
  • Provides comprehensive error checking

Implementation Details

Function Approach

  • Used a two-pointer technique to reverse strings in-place
  • Converts input string to a list of characters for manipulation
  • Swaps characters from both ends of the string towards the center
  • Converts modified list back to a string

Key Implementation Features

  • Type checking for input validation
  • Handles empty strings
  • Supports Unicode and special characters
  • O(n) time complexity
  • O(n) space complexity

Acceptance Criteria Met

  • ✅ Manually implemented string reversal
  • ✅ No use of slice notation or reverse()
  • ✅ Comprehensive error handling
  • ✅ Supports various input types and edge cases
  • ✅ All tests passing

Testing Approach

  • Implemented 7 comprehensive test cases covering:
    1. Normal string reversal
    2. Empty string handling
    3. Single character strings
    4. Strings with spaces
    5. Strings with special characters
    6. Unicode string support
    7. Invalid input type detection

Test Results

  • All 7 test cases passed successfully
  • 100% test coverage
  • No unexpected side effects or edge case failures

Potential Improvements

  • Could potentially optimize for extremely large strings
  • Consider adding more explicit type hinting in future iterations

Changes Made

  • Implemented manual string reversal algorithm
  • Added comprehensive type checking
  • Created two-pointer reversal method
  • Maintained support for all previous test scenarios

Tests

  • Verify string reversal for normal strings
  • Confirm empty string handling
  • Check single character string reversal
  • Test strings with spaces
  • Validate special character reversal
  • Ensure unicode string support
  • Validate error handling for invalid input types

Signatures

Staking Key

BiYiK5ioyqd6c2pPvvjaSzLAhR8MMvBordhBnh9CordT: 2kzzh6Zv2eii53h8ZEzRWFXDwY6zRrygGTwr6ucXd5cqBFGNUtb4vNtt1jE8TRcStJuJAStiT2iwU184hnhDnjKzDshTHeNaTMjjFz6q5gReqbVyru3AiqPNE48CVeD7M9ussWPiyXbxsRQj2iCao1PnDtViciV3zLE2TnuhG5iiSSFsTF7SMKGwCbB5QN8Qpw1kxsxmz9YbNhcqW2hBwEWR5ABqakuuSHRaYpfe8wUJpD2CvMKwRQJsnh3rot1SazFbXDxNh9S6E9PgyU4MrnxWQDXC3QybFpZzApPHsjJZHCRQNbaCuDBDubH3SjQJSpKbg4ALejNRP9C9NWS6gDWediC8KWDg6LQd78LXEuowbuPeeVysugAp9zk

Public Key

7rnv8Gvvs8tbnnnddjozHRXqtmrMpW536PJRDxV4ua4t: 3TLtADV2dUmNYG2qhVnCfQBDroukx5vA6VXefLuEcPGBfvSnpbANtYujsmCm3ehQpbCg17kTeKNtQPnERLCNSx2a5J721H9gwhQgBmVwfdVzYiMKXRvFWrkQwKYQjxfbY1269tGyz5LM6nPdiEQmt1MVhoFHSTWyp1vPSByyaqAUisVT34uYdHgdeHEwcenqrhsSuEmcshKYXjh2R5DoqvTXbr3tqk8SbxNhit9xNNmGMyMkXaAo6Shh6ghuUudycvEqFihhPnoaTEnucQujmuBMhxkutQct4Ugmsj6SuBLJMjB5opRTgF8vopHLP3zZU1ntVBJdrMR7PQq2s2mtmNqNf6a86PFk34eEq2LzUXXbvYhZJnFGQJMfye

@momstrosity momstrosity changed the title [WIP] Implement String Reversal Function in Python Implement Manual String Reversal Function without Built-in Methods May 19, 2025
@momstrosity momstrosity marked this pull request as ready for review May 19, 2025 18:15
@laura-abro
Copy link

String Reversal Implementation

Description

Implementation of a string reversal function with comprehensive test coverage

Recommendation

APPROVE

Reasons:

  • Implements string reversal without built-in reverse methods
  • Handles various input types and edge cases
  • Provides comprehensive error handling
  • All tests pass successfully

Unmet Requirements

All requirements met

Tests

Failed Tests

No failing tests

Missing Test Cases

No missing test cases identified

Action Items

No action items required

Signatures

Staking Key

AEghvdqmRtc3fjKXfNTMJJ6WshksgWuJ9YBExgsZu8cN: L89Shv6wVUhUmq9QHJ7YDXTx8iuN7XGDV3dpAycLwwVYoGVSMzsM7y4rp6TrNGLifv55nv8P6ojzQx2Mw13rtnRYVqa9YaiaeQmUgpZzQYCxhqMDsGDscxihnfqC8o5WoR8w3jgw9admWdWduW1h9dGNrZSPjPvhM9pZrt8H3WnNx2iAhTuUZF169npR3gjdRMGVrqwbWNTPqsepqqa85hvZKpEijm48iov76bz3V8eR8ShztzyvoG2YYpvFFZ1qQuWuyR79eQh5qmNgAsKkxMC95L1akL6UsVhVrQNA8Zv5ZatD3G8jgHRrtidbtDWNP2XoYC7CrCKNYjzCGeors1Q1Zt4E5tjo3kX3YppmCm6EJkci7C4uhuHMywARtHtE38Jg

Public Key

AwXAtX7tMhL4JyB8NfXdsrqc1UifaMyap3c9bpN9RMse: 3a86kqnhUwmjcvjyZzcBtUgKsiSsmBEGVXBgttUx9tadqR6MuU675cCJ8Lq2jqht4U6kowHQDsHRuZniFqhigQspBcEoiUJgJwuaNmhgASTobazrhVXL8D7sTTqpyWAoXjksbvvryYSZVbPWtATYUXDHnk5AAKBfqpGC5tA9UekQdYqzGzHFRHmMu9PyhYZmVHcVVbxv2b3LZimi4BPNLNabJ7scZnCNhWssexUcdiVMPQty7zb81xuhNmTYqVviYSrHs8s4aQca933S2i7AiYDh4cCZS3Lw99M1r3zbkLx1agukcB1WgQQvULUCiFNeGnXhqgaHSpC7b76HCTCMCLkuiLJ77UgxrBftb4JSDYSUmvzWjvYHNAnPK71gBvK1m7wA

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants