Skip to content

Add Subsets (Power Set) problem (Recursion & Backtracking) - #56

Merged
RuslanLomaka merged 3 commits into
masterfrom
problem/subsets
Nov 6, 2026
Merged

RuslanLomaka merged 3 commits into
masterfrom
problem/subsets

Conversation

@RuslanLomaka

Copy link
Copy Markdown
Owner

Summary

  • Adds the Subsets (Power Set) problem under the Recursion & Backtracking topic (MEDIUM), slug subsets.
  • New SubsetsProblem class in problem.algorithms, following BubbleSortProblem's exact pattern for metadata and hidden-test harness.
  • The harness validates results order-independently: each returned subset is canonicalized (sorted by value) into a set and compared against the brute-force bitmask-generated expected power set, also checking the subset count equals 2^n with no duplicates.
  • Registered the problem in ProblemRegistry's constructor.
  • Added reference solutions src/test/resources/solutions/subsets.txt (iterative "double the subsets per element" approach) and subsets.wrong.txt (deliberately returns only single-element subsets, missing the empty subset and larger combinations).
  • Bumped ProblemRegistryTest's hasSize(10) to hasSize(11).

Test plan

Ran the scoped validation command (also runs Checkstyle, bound to the validate phase):

./mvnw test -Dtest=HarnessVerificationTest,ProblemDefinitionContractTest,ProblemRegistryTest

Result:

[INFO] Running com.example.onlinejava.problem.ProblemRegistryTest
[INFO] Tests run: 7, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.270 s -- in com.example.onlinejava.problem.ProblemRegistryTest
[INFO] Running com.example.onlinejava.problem.HarnessVerificationTest
[INFO] Tests run: 22, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 8.186 s -- in com.example.onlinejava.problem.HarnessVerificationTest
[INFO] Running com.example.onlinejava.problem.ProblemDefinitionContractTest
[INFO] Tests run: 22, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.062 s -- in com.example.onlinejava.problem.ProblemDefinitionContractTest

[INFO] Results:
[INFO] Tests run: 51, Failures: 0, Errors: 0, Skipped: 0
[INFO] BUILD SUCCESS

Only the whitelisted files were touched (confirmed via git diff --name-only): the new problem class, ProblemRegistry.java, the two solution files, and ProblemRegistryTest.java.

Note that the repo's own CI (.github/workflows/ci-cd.yml) will independently re-run the full suite against a real Postgres container before merge is possible.

Opened automatically by a scheduled cloud agent (every 2 hours), not auto-merged -- please review.


Generated by Claude Code

@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Tip

🎯 Customize your risk assessments

Guide how CodeRabbit assesses merge risk and security architecture risk. Highlight sensitive changes and explain your security boundaries using Merge Risk Instructions and Security Risk Instructions in your review settings. Security architecture risk assessments require the Advanced plan or above.

✅ Automatic approvals, with your rules

Let CodeRabbit approve pull requests once required threads are resolved, pre-merge checks pass, and your risk limits are met. Enable Automatic approvals in review settings, with overrides for teams or file paths.

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

@sonarqubecloud

sonarqubecloud Bot commented Oct 1, 2026

Copy link
Copy Markdown

# Conflicts:
#	src/main/java/com/example/onlinejava/problem/ProblemRegistry.java
# Conflicts:
#	src/main/java/com/example/onlinejava/problem/ProblemRegistry.java
@sonarqubecloud

sonarqubecloud Bot commented Nov 6, 2026

Copy link
Copy Markdown

@RuslanLomaka
RuslanLomaka merged commit 8867417 into master Nov 6, 2026
4 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