Skip to content

Add solution for Challenge 6 by clgp-aint-cool#1563

Merged
github-actions[bot] merged 2 commits intoRezaSi:mainfrom
clgp-aint-cool:challenge-6-clgp-aint-cool
Apr 13, 2026
Merged

Add solution for Challenge 6 by clgp-aint-cool#1563
github-actions[bot] merged 2 commits intoRezaSi:mainfrom
clgp-aint-cool:challenge-6-clgp-aint-cool

Conversation

@clgp-aint-cool
Copy link
Copy Markdown
Contributor

Challenge 6 Solution

Submitted by: @clgp-aint-cool
Challenge: Challenge 6

Description

This PR contains my solution for Challenge 6.

Changes

  • Added solution file to challenge-6/submissions/clgp-aint-cool/solution-template.go

Testing

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

Thank you for reviewing my submission! 🚀

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 8, 2026

Walkthrough

A new Go submission file was added to the challenge-6 directory containing a CountWordFrequency function that normalizes input text by removing apostrophes and converting hyphens to spaces, then counts word frequencies across whitespace-delimited tokens after lowercasing and punctuation trimming.

Changes

Cohort / File(s) Summary
Word Frequency Counter
challenge-6/submissions/clgp-aint-cool/solution-template.go
Added exported function CountWordFrequency(text string) map[string]int that normalizes and counts word frequencies in input text, handling apostrophe removal, hyphen-to-space conversion, and punctuation trimming.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

🐰 A function hops in, counting words with care,
Apostrophes stripped, hyphens split with flair,
Letters tumble down to lowercase rest,
Frequency maps emerge, each word assessed! 📊

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding a solution submission for Challenge 6 by the specified user.
Description check ✅ Passed The description is directly related to the changeset, providing context about the Challenge 6 submission and the file being added.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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
Copy Markdown
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 info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 69fc28ed-6374-40fa-a672-da70b9811ef4

📥 Commits

Reviewing files that changed from the base of the PR and between 6a002af and 117a34e.

📒 Files selected for processing (1)
  • challenge-6/submissions/clgp-aint-cool/solution-template.go

Comment on lines +26 to +30
for _, word := range strings.Fields(text) {
word = strings.ToLower(word)
word = strings.Trim(word, ".,!?\"';:-()[]{}")
wordFreq[word]++
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🌐 Web query:

In Go's standard library, does strings.Trim remove cutset characters only from the beginning and end of a string (and not from the middle)?

💡 Result:

Yes. In Go’s standard library, strings.Trim(s, cutset) only removes characters in cutset from the start and end of s (“all leading and trailing Unicode code points contained in cutset removed”)—it does not remove matching characters from the middle of the string. [1]

Source: [1]


🏁 Script executed:

cat -n challenge-6/submissions/clgp-aint-cool/solution-template.go | head -35

Repository: RezaSi/go-interview-practice

Length of output: 1391


Normalization misses non-trimmed characters and can count empty keys.

The function contract (lines 14–17) requires that "all punctuation, spaces, and other non-alphanumeric characters are ignored." However, line 28's strings.Trim() only removes the specified punctuation from token boundaries, leaving internal non-alphanumeric characters untouched. For example, characters like / in "go/go" remain inside the token, violating the contract. Additionally, line 29 can increment wordFreq[""] when a token consists entirely of characters in the trim set.

Use strings.Map() with unicode.IsLetter() and unicode.IsDigit() to treat all non-alphanumeric characters as separators, ensuring proper normalization.

@github-actions github-actions Bot merged commit 858796c into RezaSi:main Apr 13, 2026
6 checks passed
@github-actions
Copy link
Copy Markdown

🎉 Auto-merged!

This PR was automatically merged after 2 days with all checks passing.

Thank you for your contribution, @clgp-aint-cool!

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