forked from exercism/problem-specifications
-
Notifications
You must be signed in to change notification settings - Fork 0
/
custom-set.json
277 lines (277 loc) · 8.15 KB
/
custom-set.json
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
{
"#": [
"These tests cover the core components of a set data structure: checking",
"presence, adding, comparing and basic set operations. Other features",
"such as deleting elements, checking size, sorting are not tested, but",
"you can add them if they are interesting in your language",
"",
"Tests about mixed-type sets are not included because the ability",
"to implement that will vary by language. If your language supports it",
"and you want to implement mixed-type sets, feel free."
],
"empty": {
"description": "Returns true if the set contains no elements",
"cases": [
{
"description": "sets with no elements are empty",
"set": [],
"expected": true
},
{
"description": "sets with elements are not empty",
"set": [1],
"expected": false
}
]
},
"contains": {
"description": "Sets can report if they contain an element",
"cases": [
{
"description": "nothing is contained in an empty set",
"set": [],
"element": 1,
"expected": false
},
{
"description": "when the element is in the set",
"set": [1, 2, 3],
"element": 1,
"expected": true
},
{
"description": "when the element is not in the set",
"set": [1, 2, 3],
"element": 4,
"expected": false
}
]
},
"subset": {
"description": "A set is a subset if all of its elements are contained in the other set",
"cases": [
{
"description": "empty set is a subset of another empty set",
"set1": [],
"set2": [],
"expected": true
},
{
"description": "empty set is a subset of non-empty set",
"set1": [],
"set2": [1],
"expected": true
},
{
"description": "non-empty set is not a subset of empty set",
"set1": [1],
"set2": [],
"expected": false
},
{
"description": "set is a subset of set with exact same elements",
"set1": [1, 2, 3],
"set2": [1, 2, 3],
"expected": true
},
{
"description": "set is a subset of larger set with same elements",
"set1": [1, 2, 3],
"set2": [4, 1, 2, 3],
"expected": true
},
{
"description": "set is not a subset of set that does not contain its elements",
"set1": [1, 2, 3],
"set2": [4, 1, 3],
"expected": false
}
]
},
"disjoint": {
"description": "Sets are disjoint if they share no elements",
"cases": [
{
"description": "the empty set is disjoint with itself",
"set1": [],
"set2": [],
"expected": true
},
{
"description": "empty set is disjoint with non-empty set",
"set1": [],
"set2": [1],
"expected": true
},
{
"description": "non-empty set is disjoint with empty set",
"set1": [1],
"set2": [],
"expected": true
},
{
"description": "sets are not disjoint if they share an element",
"set1": [1, 2],
"set2": [2, 3],
"expected": false
},
{
"description": "sets are disjoint if they share no elements",
"set1": [1, 2],
"set2": [3, 4],
"expected": true
}
]
},
"equal": {
"description": "Sets with the same elements are equal",
"cases": [
{
"description": "empty sets are equal",
"set1": [],
"set2": [],
"expected": true
},
{
"description": "empty set is not equal to non-empty set",
"set1": [],
"set2": [1, 2, 3],
"expected": false
},
{
"description": "non-empty set is not equal to empty set",
"set1": [1, 2, 3],
"set2": [],
"expected": false
},
{
"description": "sets with the same elements are equal",
"set1": [1, 2],
"set2": [2, 1],
"expected": true
},
{
"description": "sets with different elements are not equal",
"set1": [1, 2, 3],
"set2": [1, 2, 4],
"expected": false
}
]
},
"add": {
"description": "Unique elements can be added to a set",
"cases": [
{
"description": "add to empty set",
"set": [],
"element": 3,
"expected": [3]
},
{
"description": "add to non-empty set",
"set": [1, 2, 4],
"element": 3,
"expected": [1, 2, 3, 4]
},
{
"description": "adding an existing element does not change the set",
"set": [1, 2, 3],
"element": 3,
"expected": [1, 2, 3]
}
]
},
"intersection": {
"description": "Intersect returns a set of all shared elements",
"cases": [
{
"description": "intersection of two empty sets is an empty set",
"set1": [],
"set2": [],
"expected": []
},
{
"description": "intersection of an empty set and non-empty set is an empty set",
"set1": [],
"set2": [3, 2, 5],
"expected": []
},
{
"description": "intersection of a non-empty set and an empty set is an empty set",
"set1": [1, 2, 3, 4],
"set2": [],
"expected": []
},
{
"description": "intersection of two sets with no shared elements is an empty set",
"set1": [1, 2, 3],
"set2": [4, 5, 6],
"expected": []
},
{
"description": "intersection of two sets with shared elements is a set of the shared elements",
"set1": [1, 2, 3, 4],
"set2": [3, 2, 5],
"expected": [2, 3]
}
]
},
"difference": {
"description": "Difference (or Complement) of a set is a set of all elements that are only in the first set",
"cases": [
{
"description": "difference of two empty sets is an empty set",
"set1": [],
"set2": [],
"expected": []
},
{
"description": "difference of empty set and non-empty set is an empty set",
"set1": [],
"set2": [3, 2, 5],
"expected": []
},
{
"description": "difference of a non-empty set and an empty set is the non-empty set",
"set1": [1, 2, 3, 4],
"set2": [],
"expected": [1, 2, 3, 4]
},
{
"description": "difference of two non-empty sets is a set of elements that are only in the first set",
"set1": [3, 2, 1],
"set2": [2, 4],
"expected": [1, 3]
}
]
},
"union": {
"description": "Union returns a set of all elements in either set",
"cases": [
{
"description": "union of empty sets is an empty set",
"set1": [],
"set2": [],
"expected": []
},
{
"description": "union of an empty set and non-empty set is the non-empty set",
"set1": [],
"set2": [2],
"expected": [2]
},
{
"description": "union of a non-empty set and empty set is the non-empty set",
"set1": [1, 3],
"set2": [],
"expected": [1, 3]
},
{
"description": "union of non-empty sets contains all unique elements",
"set1": [1, 3],
"set2": [2, 3],
"expected": [3, 2, 1]
}
]
}
}