Repository navigation
Conversation
WalkthroughThe PR adds a Go command-line solution that reads one line, reverses it with ChangesString reversal solution
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: 🟡 Moderate · up to This solution can produce incorrect output for multi-byte UTF-8 input because it counts characters but indexes the string by bytes; merge should wait for this bug to be corrected. Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
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. Comment Warning |
|
Challenge 2 Solution |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 13bcd88c-4127-428b-b90b-3a61017f4887
📒 Files selected for processing (1)
challenge-2/submissions/gootibi/solution-template.go
Included review availability: Your plan provides up to 8 included reviews per hour; 5 remain after this review.
| for i := len(runes) - 1; i > -1; i-- { | ||
| output = append(output, string(s[i])) | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
file="challenge-2/submissions/gootibi/solution-template.go"
if rg -n 'output = append\(output, string\(s\[i\]\)\)' "$file"; then
echo "ReverseString still indexes bytes instead of runes." >&2
exit 1
fi
rg -n 'output = append\(output, string\(runes\[i\]\)\)' "$file"Repository: RezaSi/go-interview-practice
Length of output: 261
🏁 Script executed:
#!/bin/bash
set -euo pipefail
file="challenge-2/submissions/gootibi/solution-template.go"
cat -n "$file" | sed -n '1,80p'
python3 - <<'PY'
def candidate(s):
runes = list(s)
output = []
# Model Go's s[i] byte indexing and string(byte) conversion.
data = s.encode("utf-8")
for i in range(len(runes) - 1, -1, -1):
output.append(bytes([data[i]]).decode("utf-8", errors="replace"))
return "".join(output)
def rune_indexed(s):
runes = list(s)
return "".join(runes[i] for i in range(len(runes) - 1, -1, -1))
for value in ("abc", "hé", "世界", "🙂a"):
print(repr(value), "candidate=", repr(candidate(value)), "expected=", repr(rune_indexed(value)))
PYRepository: RezaSi/go-interview-practice
Length of output: 1142
Index runes instead of s.
len(runes) counts Unicode code points, but s[i] reads bytes. Multi-byte UTF-8 input produces invalid output. Use runes[i] to preserve each character.
Challenge 2 Solution
Submitted by: @gootibi
Challenge: Challenge 2
Description
This PR contains my solution for Challenge 2.
Changes
challenge-2/submissions/gootibi/solution-template.goTesting
Thank you for reviewing my submission! 🚀