Skip to content

Conversation

@kiramux
Copy link
Contributor

@kiramux kiramux commented Nov 7, 2025

Challenge 27 Solution

Submitted by: @kiramux
Challenge: Challenge 27

Description

This PR contains my solution for Challenge 27.

Changes

  • Added solution file to challenge-27/submissions/kiramux/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 7, 2025

Walkthrough

Adds a new generics utilities library in challenge-27/submissions/kiramux/solution-template.go that provides exported generic types and functions: ErrEmptyCollection, Pair, Stack, Queue, Set, and slice utilities (Filter, Map, Reduce, Contains, FindIndex, RemoveDuplicates).

Changes

Cohort / File(s) Summary
Error sentinel
challenge-27/submissions/kiramux/solution-template.go
Added ErrEmptyCollection = errors.New("collection is empty").
Pair
challenge-27/submissions/kiramux/solution-template.go
Added Pair[T, U], NewPair[T, U](first T, second U) Pair[T, U], and func (p Pair[T,U]) Swap() Pair[U,T].
Stack
challenge-27/submissions/kiramux/solution-template.go
Added Stack[T] with NewStack, Push, Pop() (T, error), Peek() (T, error), Size, IsEmpty; Pop/Peek return ErrEmptyCollection when empty.
Queue
challenge-27/submissions/kiramux/solution-template.go
Added Queue[T] with NewQueue, Enqueue, Dequeue() (T, error), Front() (T, error), Size, IsEmpty; Dequeue/Front return ErrEmptyCollection when empty.
Set
challenge-27/submissions/kiramux/solution-template.go
Added Set[T comparable] with NewSet, Add, Remove, Contains, Size, Elements, and functions Union, Intersection, Difference.
Slice utilities
challenge-27/submissions/kiramux/solution-template.go
Added Filter[T any], Map[T,U any], Reduce[T,U any], Contains[T comparable], FindIndex[T comparable], RemoveDuplicates[T comparable].

Sequence Diagram(s)

sequenceDiagram participant C as Caller participant G as generics package participant S as internal slice/map rect rgba(0,128,0,0.05) C->>G: NewStack[T]() G->>S: create internal []T end C->>G: Push(value) G->>S: append value C->>G: Pop() alt not empty G->>S: remove last, return value G-->>C: value else empty G-->>C: ErrEmptyCollection end 
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Attention areas:
    • Verify boundary/error handling for Pop/Peek, Dequeue/Front.
    • Confirm Set uses map semantics correctly and that Union/Intersection/Difference implement expected behavior.
    • Check slice utility functions for nil/empty inputs and correctness of generics usage.

Possibly related PRs

Pre-merge checks

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: adding a Challenge 27 solution by the author kiramux. It is specific and directly related to the changeset.
Description check ✅ Passed The description is related to the changeset, explaining that it contains the Challenge 27 solution with details about the file location, testing, and code quality.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e03a9da and 9693879.

📒 Files selected for processing (1)
  • challenge-27/submissions/kiramux/solution-template.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • challenge-27/submissions/kiramux/solution-template.go

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

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 29abe40 and e03a9da.

📒 Files selected for processing (1)
  • challenge-27/submissions/kiramux/solution-template.go (1 hunks)
kiramux and others added 3 commits November 7, 2025 21:06
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@RezaSi RezaSi merged commit 2dba924 into RezaSi:main Nov 7, 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

2 participants