Skip to content

Commit 0e55a9b

Browse files
williamfisetclaude
andcommitted
Add main method with example usage to PowerSet
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 948ada9 commit 0e55a9b

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/main/java/com/williamfiset/algorithms/other/BUILD

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ java_binary(
3535
runtime_deps = [":other"],
3636
)
3737

38+
# bazel run //src/main/java/com/williamfiset/algorithms/other:PowerSet
39+
java_binary(
40+
name = "PowerSet",
41+
main_class = "com.williamfiset.algorithms.other.PowerSet",
42+
runtime_deps = [":other"],
43+
)
44+
3845
# bazel run //src/main/java/com/williamfiset/algorithms/other:SquareRootDecomposition
3946
java_binary(
4047
name = "SquareRootDecomposition",

src/main/java/com/williamfiset/algorithms/other/PowerSet.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,16 @@ private static <T> void recurse(int at, List<T> set, List<T> current, List<List<
6060
current.remove(current.size() - 1);
6161
recurse(at + 1, set, current, result);
6262
}
63+
64+
public static void main(String[] args) {
65+
List<Integer> set = List.of(1, 2, 3);
66+
67+
System.out.println("Binary method:");
68+
for (List<Integer> subset : powerSetBinary(set))
69+
System.out.println(subset);
70+
71+
System.out.println("\nRecursive method:");
72+
for (List<Integer> subset : powerSetRecursive(set))
73+
System.out.println(subset);
74+
}
6375
}

0 commit comments

Comments
 (0)