Skip to content

Conversation

@cckwes
Copy link
Contributor

@cckwes cckwes commented Dec 6, 2025

Challenge 2 Solution

Submitted by: @cckwes
Challenge: Challenge 2

Description

This PR contains my solution for Challenge 2.

Changes

  • Added solution file to challenge-2/submissions/cckwes/solution-template.go

Testing

  • Solution passes all test cases
  • Code follows Go best practices

Thank you for reviewing my submission! 🚀

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 6, 2025

Walkthrough

Adds a new Go program that implements a ReverseString function to reverse strings by converting to runes and reversing the slice. The main function reads a line from standard input, calls ReverseString, and prints the result.

Changes

Cohort / File(s) Change Summary
Challenge 2 Solution
challenge-2/submissions/cckwes/solution-template.go
Adds ReverseString(s string) string function that reverses a string by converting it to a rune slice, reversing the slice, and returning the result. Includes a main function that reads a line from stdin, reverses it, and prints the output.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

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 accurately summarizes the main change: adding a solution for Challenge 2 by the specified user, matching the changeset content.
Description check ✅ Passed The description is directly related to the changeset, explaining the Challenge 2 solution submission, the file added, and testing status.

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-2/submissions/cckwes/solution-template.go (2)

9-21: main flow is correct; only minor robustness tweaks are possible

The stdin → process → stdout flow is clean and idiomatic for this challenge. If this were used beyond the kata, you might:

  • Loop on scanner.Scan() to handle multiple lines.
  • Check scanner.Err() after the scan for input errors.

For the current challenge, this is fine as-is.


23-34: ReverseString is correct and Unicode-safe; in-place reversal would avoid an extra allocation

Implementation is clear, handles multi‑byte runes correctly, and is easy to read. If you want to tighten it further, you could reverse the runes slice in place instead of allocating result, which saves one allocation/copy while keeping the same behavior:

-func ReverseString(s string) string {
-    runes := []rune(s)
-    stringLength := len(runes)
-    result := make([]rune, stringLength)
-    
-    for i := 0; i < stringLength; i++ {
-        result[stringLength - 1 - i] = runes[i]
-    }
-    
-	return string(result)
-}
+func ReverseString(s string) string {
+	runes := []rune(s)
+	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
+		runes[i], runes[j] = runes[j], runes[i]
+	}
+	return string(runes)
+}

Not required for correctness, just a small optimization.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3c11b07 and d7c4458.

📒 Files selected for processing (1)
  • challenge-2/submissions/cckwes/solution-template.go (1 hunks)

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