Skip to content

Add solution for Challenge 19 by inok94#1429

Open
inok94 wants to merge 1 commit intoRezaSi:mainfrom
inok94:challenge-19-inok94
Open

Add solution for Challenge 19 by inok94#1429
inok94 wants to merge 1 commit intoRezaSi:mainfrom
inok94:challenge-19-inok94

Conversation

@inok94
Copy link
Contributor

@inok94 inok94 commented Feb 25, 2026

Challenge 19 Solution

Submitted by: @inok94
Challenge: Challenge 19

Description

This PR contains my solution for Challenge 19.

Changes

  • Added solution file to challenge-19/submissions/inok94/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 Feb 25, 2026

Walkthrough

A new Go solution file is added with four utility functions for integer slice operations: FindMax returns the maximum value, RemoveDuplicates removes duplicates preserving order, ReverseSlice reverses elements, and FilterEven filters even numbers. A main function demonstrates their usage.

Changes

Cohort / File(s) Summary
Challenge 19 Solution
challenge-19/submissions/inok94/solution-template.go
New file introducing four integer slice utility functions: FindMax (returns max or 0 if empty), RemoveDuplicates (preserves order), ReverseSlice, and FilterEven. Includes main function demonstrating usage of all utilities.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

🐰 Hop, hop, slice and sort!
Four functions to report,
Max and filter, reverse the way,
Duplicates removed to play,
Utility magic on display!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely identifies the main change: adding a solution for Challenge 19 by a specific user.
Description check ✅ Passed The description is directly related to the changeset, explaining the purpose and contents of the solution submission for Challenge 19.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


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.

🧹 Nitpick comments (2)
challenge-19/submissions/inok94/solution-template.go (2)

34-40: Variable max shadows the Go 1.21+ built-in.

Since this repo targets Go 1.22.10, naming the local variable max shadows the built-in max function. Consider renaming it (e.g., maxVal) to avoid the shadow.

♻️ Proposed rename
-	max := numbers[0]
-	for _, number := range numbers[1:] {
-	    if max <= number {
-	        max = number
-	    }
-	}
-	return max
+	maxVal := numbers[0]
+	for _, number := range numbers[1:] {
+	    if maxVal < number {
+	        maxVal = number
+	    }
+	}
+	return maxVal

46-48: Redundant empty-slice early returns in RemoveDuplicates, ReverseSlice, and FilterEven.

All three guards are unnecessary: when len == 0, the subsequent make calls produce an empty slice, the loops don't execute, and the function returns correctly without them. FindMax genuinely needs its guard (to protect numbers[0]), but the other three don't.

♻️ Proposed cleanup (shown for `RemoveDuplicates`; apply the same to `ReverseSlice` and `FilterEven`)
 func RemoveDuplicates(numbers []int) []int {
-	if len(numbers) == 0 {
-	    return []int{}
-	}
 	duplicates := make(map[int]bool)
 	result := make([]int, 0, len(numbers))
 	...

Also applies to: 63-65, 77-79


ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a7ac764 and 8e1dbf8.

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

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