-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathset.test.ts
53 lines (53 loc) · 1.85 KB
/
set.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import { assertEquals } from "STD/assert/equals";
import { assertThrows } from "STD/assert/throws";
import { combinationSet, permutationSet } from "./set.ts";
const set1 = ["a", "b", "c", "d", "e", "f"];
Deno.test("1 Combination AllowRepeat 3", { permissions: "none" }, () => {
const result = Array.from(combinationSet(set1, 3, {
allowRepeat: true
}));
console.log(result);
assertEquals(result.length, 56);
});
Deno.test("1 Combination NoRepeat 3", { permissions: "none" }, () => {
const result = Array.from(combinationSet(set1, 3));
console.log(result);
assertEquals(result.length, 20);
});
Deno.test("1 Combination NoRepeat 6", { permissions: "none" }, () => {
const result = Array.from(combinationSet(set1, 6));
console.log(result);
assertEquals(result.length, 1);
});
Deno.test("1 Combination NoRepeat 3+6", { permissions: "none" }, () => {
const result = Array.from(combinationSet(set1, [3, 6]));
console.log(result);
assertEquals(result.length, 21);
});
Deno.test("1 Permutation AllowRepeat 3", { permissions: "none" }, () => {
const result = Array.from(permutationSet(set1, 3, {
allowRepeat: true
}));
console.log(result);
assertEquals(result.length, 216);
});
Deno.test("1 Permutation NoRepeat 3", { permissions: "none" }, () => {
const result = Array.from(permutationSet(set1, 3));
console.log(result);
assertEquals(result.length, 120);
});
Deno.test("1 Permutation NoRepeat 6", { permissions: "none" }, () => {
const result = Array.from(permutationSet(set1, 6));
console.log(result);
assertEquals(result.length, 720);
});
Deno.test("1 Permutation NoRepeat 3+6", { permissions: "none" }, () => {
const result = Array.from(permutationSet(set1, [3, 6]));
console.log(result);
assertEquals(result.length, 840);
});
Deno.test("1 Permutation NoRepeat 9", { permissions: "none" }, () => {
assertThrows(() => {
Array.from(permutationSet(set1, 9));
});
});