Skip to content

Conversation

@Johrespi
Copy link
Contributor

@Johrespi Johrespi commented Nov 9, 2025

Challenge 19 Solution

Submitted by: @Johrespi
Challenge: Challenge 19

Description

This PR contains my solution for Challenge 19.

Changes

  • Added solution file to challenge-19/submissions/Johrespi/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 Nov 9, 2025

Walkthrough

A new submission file is added containing four public slice utility functions for Go: FindMax, RemoveDuplicates, ReverseSlice, and FilterEven. Each function operates on integer slices with specific behaviors. A main function demonstrates their usage.

Changes

Cohort / File(s) Change Summary
New solution file
challenge-19/submissions/Johrespi/solution-template.go
Adds four exported slice utility functions: FindMax returns the maximum value in a slice; RemoveDuplicates removes duplicates while preserving order; ReverseSlice returns elements in reverse order; FilterEven returns only even numbers. Includes a main function demonstrating all utilities.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Verify correctness of logic in each of the four utility functions (edge cases like empty slices, single elements)
  • Check that RemoveDuplicates properly preserves original order
  • Confirm ReverseSlice doesn't mutate the original slice
  • Validate FilterEven correctly identifies and returns only even numbers

Possibly related PRs

  • #601: Adds the same four exported slice utility functions (FindMax, RemoveDuplicates, ReverseSlice, FilterEven) with identical signatures in a different submission file
  • #716: Adds the same four exported functions and demonstrating main in another challenge-19 solution-template.go submission

Pre-merge checks

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Add solution for Challenge 19 by Johrespi' accurately summarizes the main change—adding a solution file for Challenge 19.
Description check ✅ Passed The description is directly related to the changeset, clearly explaining the Challenge 19 solution submission with details about the changes and testing.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage 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
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 (4)
challenge-19/submissions/Johrespi/solution-template.go (4)

28-45: Remove TODO comment and run gofmt.

The function logic is correct and handles edge cases appropriately. However:

  • Line 31 contains a TODO comment that should be removed since the function is implemented.
  • Indentation is inconsistent (mixing spaces and tabs). Go convention strongly prefers tabs.

Run gofmt to automatically fix formatting:

#!/bin/bash
# Format the Go file according to Go conventions
gofmt -w challenge-19/submissions/Johrespi/solution-template.go

47-67: Remove TODO comment.

The implementation correctly removes duplicates while preserving order using a map-based approach with struct{}{} as the value type, which is a good Go practice for sets.

Apply this diff:

-	// TODO: Implement this function
-	

69-83: Remove TODO comment.

The implementation correctly reverses the slice by iterating backwards.

Apply this diff:

-	// TODO: Implement this function
-	

87-105: Remove TODO comment and simplify return logic.

The filtering logic is correct. However:

  • Line 88 contains a TODO comment that should be removed.
  • Lines 100-102 are redundant. If res is empty, it's already []int{}, so you can return it directly.

Apply this diff:

 	var res []int
 	for _, e := range numbers {
 	    if e % 2 == 0 {
 	        res = append(res, e)
 	    }
 	}
 	
-	if len(res) == 0 {
-	    return []int{}
-	}
-	
 	return res

Also remove the TODO comment:

-	// TODO: Implement this function
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4085963 and 59f49c1.

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

7-26: LGTM!

The demonstration code clearly exercises all four utility functions and provides useful output.

@RezaSi RezaSi merged commit 28d2979 into RezaSi:main Nov 10, 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