Skip to content

Add solution for Challenge 3 by saranyakuringi#1677

Open
saranyakuringi wants to merge 4 commits into
RezaSi:mainfrom
saranyakuringi:challenge-3-saranyakuringi
Open

Add solution for Challenge 3 by saranyakuringi#1677
saranyakuringi wants to merge 4 commits into
RezaSi:mainfrom
saranyakuringi:challenge-3-saranyakuringi

Conversation

@saranyakuringi
Copy link
Copy Markdown
Contributor

Challenge 3 Solution

Submitted by: @saranyakuringi
Challenge: Challenge 3

Description

This PR contains my solution for Challenge 3.

Changes

  • Added solution file to challenge-3/submissions/saranyakuringi/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 May 13, 2026

Review Change Stack

Walkthrough

Adds Employee and Manager types with methods to add/remove employees, compute average salary, find by ID, and a main demonstrating these operations.

Changes

Employee Manager Implementation

Layer / File(s) Summary
Data structures and package setup
challenge-3/submissions/saranyakuringi/solution-template.go
Defines Employee (ID, Name, Age, Salary) and Manager (holding []Employee).
Add and remove operations
challenge-3/submissions/saranyakuringi/solution-template.go
AddEmployee appends an employee; RemoveEmployee removes the first matching ID via slice splicing.
Average salary computation
challenge-3/submissions/saranyakuringi/solution-template.go
GetAverageSalary returns 0 for no employees and otherwise sums Salary and divides by the employee count.
Lookup operation
challenge-3/submissions/saranyakuringi/solution-template.go
FindEmployeeByID scans the slice and returns a pointer to the matched employee or nil.
Main demonstration
challenge-3/submissions/saranyakuringi/solution-template.go
main creates a manager, adds two employees, removes one, computes and prints average salary, and finds/prints an employee if present.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 I hop through lists with a pen so spry,
I add, I slice, I total — give it a try.
Salaries tallied, an ID to find,
A tidy little manager, simple and kind. 🥕

🚥 Pre-merge checks | ✅ 4 | ❌ 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 (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Add solution for Challenge 3 by saranyakuringi' directly describes the main change - adding a Challenge 3 solution submission by a specific contributor.
Description check ✅ Passed The description clearly relates to the changeset, explaining that it contains a solution for Challenge 3 with implementation details and a testing checklist.
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.

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

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 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: 167573e7-a13a-432d-a6b7-fe47a79e92dd

📥 Commits

Reviewing files that changed from the base of the PR and between 432ab82 and ab9a251.

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

Comment thread challenge-3/submissions/saranyakuringi/solution-template.go
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: 23a85d8b-4d59-4b16-8d0a-5b4f927835ff

📥 Commits

Reviewing files that changed from the base of the PR and between ab9a251 and 4293213.

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

Comment thread challenge-3/submissions/saranyakuringi/solution-template.go
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: 00f270fe-b906-4aa0-8930-6c80f3b7f47d

📥 Commits

Reviewing files that changed from the base of the PR and between 4293213 and 5b24379.

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

Comment on lines +23 to +27
for i := 0; i < len(m.Employees); i++ {
if m.Employees[i].ID == id {
+ m.Employees = append(m.Employees[:i], m.Employees[i+1:]...)
+ return
+ }
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 | 🔴 Critical | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify no diff-marker '+' prefixes remain in the reviewed file.
rg -n '^\+' challenge-3/submissions/saranyakuringi/solution-template.go

Repository: RezaSi/go-interview-practice

Length of output: 161


Remove diff markers from Go code at lines 25–27.

Lines 25–27 contain leading + characters that make the function invalid Go syntax, causing the CI failure (unexpected keyword return, expected expression). Remove the + prefixes before each statement:

Proposed fix
 func (m *Manager) RemoveEmployee(id int) {
 for i := 0; i < len(m.Employees); i++ {
 		if m.Employees[i].ID == id {
-+			m.Employees = append(m.Employees[:i], m.Employees[i+1:]...)
-+			return
-+		}
+			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
for i := 0; i < len(m.Employees); i++ {
if m.Employees[i].ID == id {
+ m.Employees = append(m.Employees[:i], m.Employees[i+1:]...)
+ return
+ }
func (m *Manager) RemoveEmployee(id int) {
for i := 0; i < len(m.Employees); i++ {
if m.Employees[i].ID == id {
m.Employees = append(m.Employees[:i], m.Employees[i+1:]...)
return
}
}
}
🧰 Tools
🪛 GitHub Actions: PR Tests / 1_test-submissions (challenge-3).txt

[error] 26-26: Go test failed with syntax error: unexpected keyword return, expected expression at ./solution-template.go:26:5.

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