Skip to content

Conversation

@hudazaan
Copy link
Contributor

Challenge 17 Solution

Submitted by: @hudazaan

Challenge: Challenge 17

Description:

This PR contains my solution file in challenge-17/submissions/hudazaan/solution-template.go for challenge 17.

Testing

  • Solution passes all Test cases.
  • Code follows Go best practices.

Thank you for reviewing my PR. Looking forward to more meaningful contributions!! 🚀

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 15, 2025

Walkthrough

Adds a Go palindrome checker program. Introduces exported function IsPalindrome(s string) bool that normalizes input (remove non-alphanumerics, lowercase) and uses two-pointer comparison. Includes a main function to read input, call IsPalindrome, and print the result. Uses only standard library packages.

Changes

Cohort / File(s) Summary of Changes
Palindrome checker implementation
challenge-17/submissions/hudazaan/solution-template.go
New Go file adding exported IsPalindrome function with normalization and two-pointer logic; adds main to read input and print whether it’s a palindrome; uses fmt, strings, unicode; no external dependencies.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant Main as main()
  participant Pal as IsPalindrome(s)

  User->>Main: Provide input string
  Main->>Pal: IsPalindrome(input)
  Note right of Pal: Normalize: remove non-alphanumerics, to lower
  Pal->>Pal: Two-pointer compare
  Pal-->>Main: bool (true/false)
  Main-->>User: Print result
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

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 succinctly conveys that this pull request adds the solution for Challenge 17, directly reflecting the main change without unnecessary detail or noise.
Description Check ✅ Passed The description clearly identifies the submission file path, outlines that the solution passes tests and follows Go best practices, and directly relates to Challenge 17 without going off-topic.

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: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a2868df and 043b47b.

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

24-50: LGTM! Clean and efficient implementation.

The palindrome logic is correct and follows Go best practices:

  • Efficient use of strings.Builder for string construction
  • Proper Unicode handling with unicode.IsLetter and unicode.IsDigit
  • Optimal two-pointer approach for O(n) comparison
  • Clear comments and readable code

Comment on lines +9 to +22
func main() {
// Get input from the user
var input string
fmt.Print("Enter a string to check if it's a palindrome: ")
fmt.Scanln(&input)

// Call the IsPalindrome function and print the result
result := IsPalindrome(input)
if result {
fmt.Println("The string is a palindrome.")
} else {
fmt.Println("The string is not a palindrome.")
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Use bufio.Scanner to read multi-word input.

fmt.Scanln stops reading at the first whitespace, which breaks palindrome checking for common test cases like "race car" or "A man a plan a canal Panama". Palindrome checkers typically need to handle phrases with spaces.

Apply this diff to fix the input reading:

 import (
+	"bufio"
 	"fmt"
+	"os"
 	"strings"
 	"unicode"
 )

 func main() {
 	// Get input from the user
-	var input string
 	fmt.Print("Enter a string to check if it's a palindrome: ")
-	fmt.Scanln(&input)
+	scanner := bufio.NewScanner(os.Stdin)
+	scanner.Scan()
+	input := scanner.Text()

 	// Call the IsPalindrome function and print the result
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
func main() {
// Get input from the user
var input string
fmt.Print("Enter a string to check if it's a palindrome: ")
fmt.Scanln(&input)
// Call the IsPalindrome function and print the result
result := IsPalindrome(input)
if result {
fmt.Println("The string is a palindrome.")
} else {
fmt.Println("The string is not a palindrome.")
}
}
import (
"bufio"
"fmt"
"os"
"strings"
"unicode"
)
func main() {
// Get input from the user
fmt.Print("Enter a string to check if it's a palindrome: ")
scanner := bufio.NewScanner(os.Stdin)
scanner.Scan()
input := scanner.Text()
// Call the IsPalindrome function and print the result
result := IsPalindrome(input)
if result {
fmt.Println("The string is a palindrome.")
} else {
fmt.Println("The string is not a palindrome.")
}
}
🤖 Prompt for AI Agents
In challenge-17/submissions/hudazaan/solution-template.go around lines 9 to 22,
replace the fmt.Scanln input reading with a bufio.Scanner (or bufio.NewReader)
to capture the full line including spaces: create a scanner for os.Stdin, call
scanner.Scan(), assign input = scanner.Text(), and handle scanner.Err() if
present. Also ensure bufio and os are imported (add them to the import block if
missing). This will allow multi-word phrases like "race car" to be read
correctly for palindrome checking.

@RezaSi RezaSi merged commit c2e65ef into RezaSi:main Oct 16, 2025
5 checks passed
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