Skip to content

Commit 3973bec

Browse files
committed
More combinatorica tests
1 parent ddcd9c3 commit 3973bec

1 file changed

Lines changed: 26 additions & 1 deletion

File tree

test/test_combinatorica.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,39 @@ def test_combinatorica():
9494
(
9595
"Multinomial[3,3]",
9696
"20",
97-
9897
"The built-in function Multinomial, Page 14"
9998
),
99+
(
100+
"DistinctPermutations[{A,B,C}]",
101+
"{{A, B, C}, {A, C, B}, {B, A, C}, {B, C, A}, {C, A, B}, {C, B, A}}",
102+
"DisctinctPermutations all n! permutations, Page 14"
103+
),
104+
(
105+
"Sort[ Subsets [Range[4]],(Apply[Plus, #1]<=Apply[Plus,#2])& ]",
106+
"{{}, {1}, {2}, {3}, {1, 2}, {4}, {1, 3}, {1, 4}, {2, 3}, {2, 4}, "
107+
"{1, 2, 3}, {3, 4}, {1, 2, 4}, {1, 3, 4}, {2, 3, 4}, {1, 2, 3, 4}}",
108+
"Sort to total order subsets, Page 15"
109+
),
100110
(
101111
"Subsets[Range[3]]",
102112
"{{}, {1}, {2}, {3}, {1, 2}, {1, 3}, {2, 3}, {1, 2, 3}}",
103113
"Subsets",
104114
),
115+
(
116+
"BinarySearch[Table[2i,{i, 30}],40]",
117+
"20",
118+
"BinarySearch: 40 is one of the first 30 even numbers, Page 16"
119+
),
120+
(
121+
"BinarySearch[Table[2i,{i, 30}],41]",
122+
"41/2",
123+
"BinarySearch: BinarySearch: 41 is not even"
124+
),
125+
(
126+
"BinarySearch[{2, 3, 9}, 7] // N",
127+
"2.5",
128+
"BinarySearch - mid-way insertion point",
129+
),
105130
("BinarySearch[{3, 4, 10, 100, 123}, 100]", "4", "BinarySearch find item"),
106131
(
107132
"BinarySearch[{2, 3, 9}, 7] // N",

0 commit comments

Comments
 (0)