Skip to content

Add solution for Challenge 3 by clgp-aint-cool#1560

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

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

Conversation

@clgp-aint-cool
Copy link
Copy Markdown
Contributor

Challenge 3 Solution

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

Description

This PR contains my solution for Challenge 3.

Changes

  • Added solution file to challenge-3/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 solution file has been added that defines Employee and Manager data structures along with methods for managing employees: adding, removing, calculating average salary, and finding by ID. The implementation includes a main function demonstrating these operations.

Changes

Cohort / File(s) Summary
Employee Manager Solution
challenge-3/submissions/clgp-aint-cool/solution-template.go
Added Employee struct with ID, Name, Age, and Salary fields; added Manager struct with employee slice; implemented AddEmployee, RemoveEmployee, GetAverageSalary, and FindEmployeeByID methods; included main function demonstrating manager operations.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

  • PR #879: Adds nearly identical Go solution for Challenge 3 with same Employee and Manager types and methods in a different submission directory.
  • PR #1110: Implements the same Employee and Manager structure with identical methods (AddEmployee, RemoveEmployee, GetAverageSalary, FindEmployeeByID) in challenge-3.
  • PR #818: Adds comparable Go implementation with identical Employee and Manager types and all four manager methods plus main function in a different submission.

Poem

🐰 A Manager hops and an Employee springs,
With AddEmployee bringing such wonderful things,
We search and we shuffle, remove with such flair,
Average salaries computed with care,
Challenge-3 conquered—solution so fair! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding a solution submission for Challenge 3 by a specific user.
Description check ✅ Passed The description is directly related to the changeset, clearly explaining the Challenge 3 solution submission and the file added.

✏️ 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: a9613a49-83e4-43a7-87b7-dba7a68ec895

📥 Commits

Reviewing files that changed from the base of the PR and between 6a002af and 5b45572.

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

Comment on lines +22 to +28
func (m *Manager) RemoveEmployee(id int) {
for i, e := range m.Employees {
if e.ID == id {
m.Employees = append(m.Employees[:i], m.Employees[i+1:]...)
}
}
}
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

Modifying slice while iterating can cause unexpected behavior.

After removing an element with append(m.Employees[:i], m.Employees[i+1:]...), the slice is shortened but the range loop continues. This can skip elements or cause index issues. Since employee IDs should be unique, add a return after removal to exit immediately.

🐛 Proposed fix
 func (m *Manager) RemoveEmployee(id int) {
 	for i, e := range m.Employees {
 		if e.ID == id {
 			m.Employees = append(m.Employees[:i], m.Employees[i+1:]...)
+			return
 		}
 	}
 }
📝 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 (m *Manager) RemoveEmployee(id int) {
for i, e := range m.Employees {
if e.ID == id {
m.Employees = append(m.Employees[:i], m.Employees[i+1:]...)
}
}
}
func (m *Manager) RemoveEmployee(id int) {
for i, e := range m.Employees {
if e.ID == id {
m.Employees = append(m.Employees[:i], m.Employees[i+1:]...)
return
}
}
}

@github-actions github-actions Bot merged commit 2e91b06 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