Skip to content

Add solution for Challenge 3 by WHFF521#1889

Merged
github-actions[bot] merged 1 commit into
RezaSi:mainfrom
WHFF521:challenge-3-WHFF521
Jul 16, 2026
Merged

Add solution for Challenge 3 by WHFF521#1889
github-actions[bot] merged 1 commit into
RezaSi:mainfrom
WHFF521:challenge-3-WHFF521

Conversation

@WHFF521

@WHFF521 WHFF521 commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Challenge 3 Solution

Submitted by: @WHFF521
Challenge: Challenge 3

Description

This PR contains my solution for Challenge 3.

Changes

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

Testing

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

Thank you for reviewing my submission! 🚀

@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Adds a Go employee/manager domain with slice-backed storage, employee mutation, average salary calculation, ID lookup, and a main function demonstrating these operations.

Changes

Employee manager implementation

Layer / File(s) Summary
Employee storage and mutation
challenge-3/submissions/WHFF521/solution-template.go
Defines Employee and Manager, then adds and removes employees from the manager’s slice.
Salary aggregation and lookup
challenge-3/submissions/WHFF521/solution-template.go
Calculates average salary and searches employees by ID, returning nil when no match exists.
Manager operation demonstration
challenge-3/submissions/WHFF521/solution-template.go
Runs add, remove, average, lookup, and conditional printing operations from main.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Poem

I’m a bunny with a manager’s plan,
Adding employees where carrots began.
Remove one, count the pay,
Find by ID along the way—
Go hops neatly through the day!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the submitted Challenge 3 solution by WHFF521.
Description check ✅ Passed The description clearly matches the submitted Challenge 3 solution and its testing claims.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.12.2)

level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies"


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.

@coderabbitai coderabbitai Bot left a comment

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.

🧹 Nitpick comments (1)
challenge-3/submissions/WHFF521/solution-template.go (1)

22-32: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider using slices.DeleteFunc for an idiomatic in-place removal.

The current implementation works perfectly but allocates a new slice. Since Go 1.21, the standard library provides slices.DeleteFunc, which performs an in-place filter. This approach avoids allocating a new slice while safely zero-clearing tail elements to prevent memory leaks.

// Add "slices" to your imports at the top of the file:
import (
	"fmt"
	"slices"
)
♻️ Proposed refactor
 // RemoveEmployee removes an employee by ID from the manager's list.
 func (m *Manager) RemoveEmployee(id int) {
 	// TODO: Implement this method
-	var result []Employee
-	for _,e :=range(m.Employees){
-	    if e.ID!=id{
-	        result = append(result,e)
-	    }
-	}
-	m.Employees = result
+	m.Employees = slices.DeleteFunc(m.Employees, func(e Employee) bool {
+		return e.ID == id
+	})
 }

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d7a18d9d-5607-43d4-9dd8-3c127a7f51a4

📥 Commits

Reviewing files that changed from the base of the PR and between 8522a72 and e4fb63a.

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

@github-actions
github-actions Bot merged commit 09db78f into RezaSi:main Jul 16, 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, @WHFF521!

📊 Scoreboards and badges will be updated shortly.

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.

1 participant