Skip to content

Conversation

@brenoamin
Copy link
Contributor

Challenge 2 — Reverse a String

This pull request includes the implementation for challenge-2.

✔ What’s included

  • ReverseString function using a rune-based two-pointer technique
  • Proper handling of Unicode characters

🧪 Testing

Run the tests from the challenge-2/ directory:

go test -v

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 8, 2025

Walkthrough

Two new Go solution files are added to the interview practice repository: one implementing a sum function for challenge-1 that reads and adds two comma-separated integers, and another implementing a string reversal function for challenge-2 that reverses input strings using rune-based manipulation.

Changes

Cohort / File(s) Summary
Challenge 1: Sum Implementation
challenge-1/submissions/brenoamin/solution-template.go
Adds a new Go solution that reads two comma-separated integers from standard input, computes their sum using an exported Sum(a int, b int) int function, and prints the result with error handling for input parsing.
Challenge 2: String Reversal Implementation
challenge-2/submissions/brenoamin/solution-template.go
Adds a new Go solution that reads a line from standard input, reverses it using an exported ReverseString(s string) string function (by converting to runes, reversing in place, and converting back), and prints the result.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Both solutions are straightforward implementations with minimal logic density. Review focuses on verifying correct I/O handling, basic algorithm correctness (addition and rune-based reversal), and adherence to the solution template structure.

Possibly related PRs

Pre-merge checks

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat(challenge-2): implement ReverseString solution' directly and clearly describes the main change: implementing the ReverseString solution for challenge-2.
Description check ✅ Passed The description is directly related to the changeset, explaining the Challenge 2 implementation with details about the ReverseString function, Unicode handling, and testing instructions.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
challenge-1/submissions/brenoamin/solution-template.go (1)

7-19: Input format is tightly coupled to %d, %d pattern

The fmt.Scanf("%d, %d", &a, &b) call expects a literal comma and (due to the space) typically an input like 1, 2. If the challenge harness or manual testing might provide 1,2 or 1 2, this will fail parsing. Consider whether you want a more permissive format string (e.g., whitespace‑separated) or to clearly document that the expected input is "<int>, <space><int>".

challenge-2/submissions/brenoamin/solution-template.go (1)

9-21: Optional: surface scanner errors for robustness

For the challenge this is fine, but if you want slightly more robust behavior, you could check scanner.Err() when Scan() returns false and decide whether to log/exit vs. just doing nothing.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f761321 and 85dd346.

📒 Files selected for processing (2)
  • challenge-1/submissions/brenoamin/solution-template.go (1 hunks)
  • challenge-2/submissions/brenoamin/solution-template.go (1 hunks)
🔇 Additional comments (2)
challenge-1/submissions/brenoamin/solution-template.go (1)

21-23: Sum helper is clear and correct

Sum(a, b) is trivial, side‑effect free, and matches the challenge intent; no issues here.

challenge-2/submissions/brenoamin/solution-template.go (1)

23-29: Unicode‑aware reversal is implemented correctly

The rune slice + two‑pointer swap loop correctly reverses by Unicode code point and has clean O(n) behavior. This is exactly what you want for this challenge.

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.

1 participant