Skip to content

Conversation

@cckwes
Copy link
Contributor

@cckwes cckwes commented Dec 7, 2025

Challenge 3 Solution

Submitted by: @cckwes
Challenge: Challenge 3

Description

This PR contains my solution for Challenge 3.

Changes

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

Testing

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

Thank you for reviewing my submission! 🚀

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 7, 2025

Walkthrough

A new Go file introduces an HR management model with Employee and Manager types. Manager implements methods to add/remove employees, compute average salary, find employees by ID, and includes a main function demonstrating basic usage.

Changes

Cohort / File(s) Summary
New HR management solution
challenge-3/submissions/cckwes/solution-template.go
Adds Employee struct with ID, Name, Age, Salary fields; Manager struct with Employees slice; Manager methods: AddEmployee, RemoveEmployee, GetAverageSalary, FindEmployeeByID; private helper findEmployeeIndexByID; main function demonstrates add, remove, average, and find operations.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 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 title accurately and clearly summarizes the main change: adding a solution for Challenge 3 by a specific contributor.
Description check ✅ Passed The description is directly related to the changeset, explaining the Challenge 3 solution submission, the file location, and testing confirmation.

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

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

21-29: Slice‑based removal is correct; consider signaling success/failure

The index lookup + append(m.Employees[:foundIndex], m.Employees[foundIndex+1:]...) pattern is correct and safe, including for first/last elements. Depending on the challenge requirements, you might optionally return a bool to indicate whether an employee was actually removed, which can simplify caller logic.


46-64: FindEmployeeByID + helper are fine; be aware of pointer semantics

The helper findEmployeeIndexByID is clear, and FindEmployeeByID returning nil on miss is straightforward. Returning *Employee means callers can mutate the stored employee via the pointer, and the pointer may become stale if employees are later removed/reordered—this is acceptable but worth being conscious of; alternatively, you could return an Employee value with a second bool/error result if you want stronger encapsulation.


1-78: Run gofmt for canonical Go formatting

There’s a minor mix of tabs/spaces in a few function bodies; running gofmt on this file will normalize indentation and keep it consistent with standard Go formatting, which is generally expected for Go submissions.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3c11b07 and 5aeae4e.

📒 Files selected for processing (1)
  • challenge-3/submissions/cckwes/solution-template.go (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
challenge-3/submissions/cckwes/solution-template.go (1)
challenge-13/submissions/Gandook/solution-template.go (1)
  • ID (144-144)
🔇 Additional comments (4)
challenge-3/submissions/cckwes/solution-template.go (4)

5-14: Employee / Manager structs are straightforward and idiomatic

The data modeling for Employee and Manager is clear and idiomatic for this scale; using a slice for Employees keeps things simple and readable.


16-19: AddEmployee implementation looks good

Pointer receiver plus append is the right choice here; this method is minimal and correct.


31-44: Average salary calculation handles empty slice correctly

Guarding against len(m.Employees) == 0 avoids divide‑by‑zero, and the loop is clear. Returning 0 for “no employees” is a reasonable convention; just ensure it matches the challenge spec.


66-78: main is a nice demo; double‑check it matches the challenge harness expectations

The example usage in main correctly exercises all the methods and prints sensible output. For this repo’s challenges, sometimes the tests expect only library code (no main) or a specific package/interface shape, so please confirm the challenge instructions to ensure having package main and func main() in this file won’t interfere with automated tests.

@RezaSi RezaSi merged commit b34b39f into RezaSi:main Dec 8, 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