Skip to content

Conversation

@baindraraj
Copy link
Contributor

Challenge 3 Solution

Submitted by: @baindraraj
Challenge: Challenge 3

Description

This PR contains my solution for Challenge 3.

Changes

  • Added solution file to challenge-3/submissions/baindraraj/solution-template.go

Testing

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

Thank you for reviewing my submission! 🚀

@coderabbitai
Copy link

coderabbitai bot commented Oct 22, 2025

Walkthrough

Introduces a new Go program with Employee and Manager types. The Manager provides methods to add and remove employees, calculate average salary, and search employees by ID. A main function demonstrates basic operations.

Changes

Cohort / File(s) Change Summary
New Employee Management Solution
challenge-3/submissions/baindraraj/solution-template.go
Added Employee struct with ID, Name, Age, Salary fields; Manager struct holding employee slice; methods for adding/removing employees, computing average salary, and searching by ID; demonstration main function

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Pre-merge checks

❌ 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%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The pull request title "Add solution for Challenge 3 by baindraraj" directly and clearly describes the primary change in the changeset, which is the addition of a new solution file at challenge-3/submissions/baindraraj/solution-template.go. The title is concise, specific, and appropriately identifies both what is being added (a solution) and which challenge it addresses (Challenge 3), making it immediately clear to teammates scanning the history what this PR contains.
Description Check ✅ Passed The pull request description is directly related to the changeset and appropriately documents the submission of a Challenge 3 solution. The description identifies the contributor, clearly states the purpose (solution submission), lists the file added, and includes testing verification. While the description could include technical details about the solution's implementation, it adequately conveys the intent and scope of the PR, meeting the lenient criteria for this check.

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

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

31-43: LGTM! Correct average calculation.

The GetAverageSalary method correctly handles the edge case of an empty employee list and computes the average salary properly.

Minor: Line 42 has inconsistent spacing around the / operator. Running gofmt will automatically fix this formatting.


45-54: Simplify pointer dereferencing for idiomatic Go.

The logic is correct, but line 49 uses explicit pointer dereferencing (*e).ID which is unnecessary in Go. The language automatically dereferences pointers when accessing struct fields.

Apply this diff to use idiomatic Go syntax:

 func (m *Manager) FindEmployeeByID(id int) *Employee {
 	for indx:= range m.Employees {
 	     e := &m.Employees[indx]
-	     if (*e).ID == id {
+	     if e.ID == id {
 	         return e
 	     }
 	}
 	return nil
 }

Minor: Line 47 has a spacing issue (indx:= range should be indx := range). Running gofmt will automatically fix this.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 464b940 and 3247702.

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

5-14: LGTM! Clean struct definitions.

The Employee and Manager struct definitions are well-designed with appropriate field types and follow Go naming conventions.


16-19: LGTM! Correct implementation.

The AddEmployee method correctly appends an employee to the slice using a pointer receiver.


21-29: LGTM! Correct removal logic.

The RemoveEmployee method correctly removes the first employee matching the given ID using standard Go slice manipulation.


56-68: LGTM! Good demonstration of the Manager functionality.

The main function correctly demonstrates all Manager methods with proper nil checking before accessing the found employee.

@RezaSi RezaSi closed this Oct 23, 2025
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