-
-
Notifications
You must be signed in to change notification settings - Fork 551
/
Copy pathcanonical-data.json
507 lines (507 loc) · 15.2 KB
/
canonical-data.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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
{
"exercise": "rational-numbers",
"comments": [
" The canonical data assumes mathematically correct real ",
" numbers. The testsuites should consider rounding errors ",
" instead of testing for exact values for any non-integer ",
" tests. ",
" Rational numbers r are represented as arrays [a, b] so ",
" that r = a/b. "
],
"cases": [
{
"description": "Arithmetic",
"cases": [
{
"description": "Addition",
"cases": [
{
"uuid": "0ba4d988-044c-4ed5-9215-4d0bb8d0ae9f",
"description": "Add two positive rational numbers",
"property": "add",
"input": {
"r1": [1, 2],
"r2": [2, 3]
},
"expected": [7, 6]
},
{
"uuid": "88ebc342-a2ac-4812-a656-7b664f718b6a",
"description": "Add a positive rational number and a negative rational number",
"property": "add",
"input": {
"r1": [1, 2],
"r2": [-2, 3]
},
"expected": [-1, 6]
},
{
"uuid": "92ed09c2-991e-4082-a602-13557080205c",
"description": "Add two negative rational numbers",
"property": "add",
"input": {
"r1": [-1, 2],
"r2": [-2, 3]
},
"expected": [-7, 6]
},
{
"uuid": "6e58999e-3350-45fb-a104-aac7f4a9dd11",
"description": "Add a rational number to its additive inverse",
"property": "add",
"input": {
"r1": [1, 2],
"r2": [-1, 2]
},
"expected": [0, 1]
}
]
},
{
"description": "Subtraction",
"cases": [
{
"uuid": "47bba350-9db1-4ab9-b412-4a7e1f72a66e",
"description": "Subtract two positive rational numbers",
"property": "sub",
"input": {
"r1": [1, 2],
"r2": [2, 3]
},
"expected": [-1, 6]
},
{
"uuid": "93926e2a-3e82-4aee-98a7-fc33fb328e87",
"description": "Subtract a positive rational number and a negative rational number",
"property": "sub",
"input": {
"r1": [1, 2],
"r2": [-2, 3]
},
"expected": [7, 6]
},
{
"uuid": "a965ba45-9b26-442b-bdc7-7728e4b8d4cc",
"description": "Subtract two negative rational numbers",
"property": "sub",
"input": {
"r1": [-1, 2],
"r2": [-2, 3]
},
"expected": [1, 6]
},
{
"uuid": "0df0e003-f68e-4209-8c6e-6a4e76af5058",
"description": "Subtract a rational number from itself",
"property": "sub",
"input": {
"r1": [1, 2],
"r2": [1, 2]
},
"expected": [0, 1]
}
]
},
{
"description": "Multiplication",
"cases": [
{
"uuid": "34fde77a-75f4-4204-8050-8d3a937958d3",
"description": "Multiply two positive rational numbers",
"property": "mul",
"input": {
"r1": [1, 2],
"r2": [2, 3]
},
"expected": [1, 3]
},
{
"uuid": "6d015cf0-0ea3-41f1-93de-0b8e38e88bae",
"description": "Multiply a negative rational number by a positive rational number",
"property": "mul",
"input": {
"r1": [-1, 2],
"r2": [2, 3]
},
"expected": [-1, 3]
},
{
"uuid": "d1bf1b55-954e-41b1-8c92-9fc6beeb76fa",
"description": "Multiply two negative rational numbers",
"property": "mul",
"input": {
"r1": [-1, 2],
"r2": [-2, 3]
},
"expected": [1, 3]
},
{
"uuid": "a9b8f529-9ec7-4c79-a517-19365d779040",
"description": "Multiply a rational number by its reciprocal",
"property": "mul",
"input": {
"r1": [1, 2],
"r2": [2, 1]
},
"expected": [1, 1]
},
{
"uuid": "d89d6429-22fa-4368-ab04-9e01a44d3b48",
"description": "Multiply a rational number by 1",
"property": "mul",
"input": {
"r1": [1, 2],
"r2": [1, 1]
},
"expected": [1, 2]
},
{
"uuid": "0d95c8b9-1482-4ed7-bac9-b8694fa90145",
"description": "Multiply a rational number by 0",
"property": "mul",
"input": {
"r1": [1, 2],
"r2": [0, 1]
},
"expected": [0, 1]
}
]
},
{
"description": "Division",
"cases": [
{
"uuid": "1de088f4-64be-4e6e-93fd-5997ae7c9798",
"description": "Divide two positive rational numbers",
"property": "div",
"input": {
"r1": [1, 2],
"r2": [2, 3]
},
"expected": [3, 4]
},
{
"uuid": "7d7983db-652a-4e66-981a-e921fb38d9a9",
"description": "Divide a positive rational number by a negative rational number",
"property": "div",
"input": {
"r1": [1, 2],
"r2": [-2, 3]
},
"expected": [-3, 4]
},
{
"uuid": "1b434d1b-5b38-4cee-aaf5-b9495c399e34",
"description": "Divide two negative rational numbers",
"property": "div",
"input": {
"r1": [-1, 2],
"r2": [-2, 3]
},
"expected": [3, 4]
},
{
"uuid": "d81c2ebf-3612-45a6-b4e0-f0d47812bd59",
"description": "Divide a rational number by 1",
"property": "div",
"input": {
"r1": [1, 2],
"r2": [1, 1]
},
"expected": [1, 2]
}
]
}
]
},
{
"description": "Absolute value",
"cases": [
{
"uuid": "5fee0d8e-5955-4324-acbe-54cdca94ddaa",
"description": "Absolute value of a positive rational number",
"property": "abs",
"input": {
"r": [1, 2]
},
"expected": [1, 2]
},
{
"uuid": "3cb570b6-c36a-4963-a380-c0834321bcaa",
"description": "Absolute value of a positive rational number with negative numerator and denominator",
"property": "abs",
"input": {
"r": [-1, -2]
},
"expected": [1, 2]
},
{
"uuid": "6a05f9a0-1f6b-470b-8ff7-41af81773f25",
"description": "Absolute value of a negative rational number",
"property": "abs",
"input": {
"r": [-1, 2]
},
"expected": [1, 2]
},
{
"uuid": "5d0f2336-3694-464f-8df9-f5852fda99dd",
"description": "Absolute value of a negative rational number with negative denominator",
"property": "abs",
"input": {
"r": [1, -2]
},
"expected": [1, 2]
},
{
"uuid": "f8e1ed4b-9dca-47fb-a01e-5311457b3118",
"description": "Absolute value of zero",
"property": "abs",
"input": {
"r": [0, 1]
},
"expected": [0, 1]
},
{
"uuid": "4a8c939f-f958-473b-9f88-6ad0f83bb4c4",
"description": "Absolute value of a rational number is reduced to lowest terms",
"property": "abs",
"input": {
"r": [2, 4]
},
"expected": [1, 2]
}
]
},
{
"description": "Exponentiation of a rational number",
"cases": [
{
"uuid": "ea2ad2af-3dab-41e7-bb9f-bd6819668a84",
"description": "Raise a positive rational number to a positive integer power",
"property": "exprational",
"input": {
"r": [1, 2],
"n": 3
},
"expected": [1, 8]
},
{
"uuid": "8168edd2-0af3-45b1-b03f-72c01332e10a",
"description": "Raise a negative rational number to a positive integer power",
"property": "exprational",
"input": {
"r": [-1, 2],
"n": 3
},
"expected": [-1, 8]
},
{
"uuid": "c291cfae-cfd8-44f5-aa6c-b175c148a492",
"description": "Raise a positive rational number to a negative integer power",
"property": "exprational",
"input": {
"r": [3, 5],
"n": -2
},
"expected": [25, 9]
},
{
"uuid": "45cb3288-4ae4-4465-9ae5-c129de4fac8e",
"description": "Raise a negative rational number to an even negative integer power",
"property": "exprational",
"input": {
"r": [-3, 5],
"n": -2
},
"expected": [25, 9]
},
{
"uuid": "2d47f945-ffe1-4916-a399-c2e8c27d7f72",
"description": "Raise a negative rational number to an odd negative integer power",
"property": "exprational",
"input": {
"r": [-3, 5],
"n": -3
},
"expected": [-125, 27]
},
{
"uuid": "e2f25b1d-e4de-4102-abc3-c2bb7c4591e4",
"description": "Raise zero to an integer power",
"property": "exprational",
"input": {
"r": [0, 1],
"n": 5
},
"expected": [0, 1]
},
{
"uuid": "431cac50-ab8b-4d58-8e73-319d5404b762",
"description": "Raise one to an integer power",
"property": "exprational",
"input": {
"r": [1, 1],
"n": 4
},
"expected": [1, 1]
},
{
"uuid": "7d164739-d68a-4a9c-b99f-dd77ce5d55e6",
"description": "Raise a positive rational number to the power of zero",
"property": "exprational",
"input": {
"r": [1, 2],
"n": 0
},
"expected": [1, 1]
},
{
"uuid": "eb6bd5f5-f880-4bcd-8103-e736cb6e41d1",
"description": "Raise a negative rational number to the power of zero",
"property": "exprational",
"input": {
"r": [-1, 2],
"n": 0
},
"expected": [1, 1]
}
]
},
{
"description": "Exponentiation of a real number to a rational number",
"cases": [
{
"uuid": "30b467dd-c158-46f5-9ffb-c106de2fd6fa",
"description": "Raise a real number to a positive rational number",
"property": "expreal",
"input": {
"x": 8,
"r": [4, 3]
},
"expected": 16.0
},
{
"uuid": "6e026bcc-be40-4b7b-ae22-eeaafc5a1789",
"description": "Raise a real number to a negative rational number",
"property": "expreal",
"input": {
"x": 9,
"r": [-1, 2]
},
"expected": 0.3333333333333333
},
{
"uuid": "9f866da7-e893-407f-8cd2-ee85d496eec5",
"description": "Raise a real number to a zero rational number",
"property": "expreal",
"input": {
"x": 2,
"r": [0, 1]
},
"expected": 1.0
},
{
"uuid": "da137f1c-fc94-4035-9813-94f5152a1102",
"description": "Raise a negative real number to a rational number that has been reduced",
"property": "expreal",
"input": {
"x": -1,
"r": [1, 1]
},
"expected": -1.0
},
{
"uuid": "9abd9332-eeab-4139-afa2-2f82efdae421",
"description": "Raise a negative real number to a rational number that has not been reduced",
"property": "expreal",
"input": {
"x": -1,
"r": [2, 2]
},
"expected": -1.0
},
{
"uuid": "f3734f78-91b2-4e59-905e-8c61dbf34f39",
"description": "Fails with a negative real number if the denominator of the reduced rational number is even",
"property": "expreal",
"input": {
"x": -1,
"r": [1, 2]
},
"expected": {
"error": "the result of this operation is a complex number"
}
}
]
},
{
"description": "Reduction to lowest terms",
"cases": [
{
"uuid": "0a63fbde-b59c-4c26-8237-1e0c73354d0a",
"description": "Reduce a positive rational number to lowest terms",
"property": "reduce",
"input": {
"r": [2, 4]
},
"expected": [1, 2]
},
{
"uuid": "5ed6f248-ad8d-4d4e-a545-9146c6727f33",
"description": "Reduce places the minus sign on the numerator",
"property": "reduce",
"input": {
"r": [3, -4]
},
"expected": [-3, 4]
},
{
"uuid": "f87c2a4e-d29c-496e-a193-318c503e4402",
"description": "Reduce a negative rational number to lowest terms",
"property": "reduce",
"input": {
"r": [-4, 6]
},
"expected": [-2, 3]
},
{
"uuid": "3b92ffc0-5b70-4a43-8885-8acee79cdaaf",
"description": "Reduce a rational number with a negative denominator to lowest terms",
"property": "reduce",
"input": {
"r": [3, -9]
},
"expected": [-1, 3]
},
{
"uuid": "c9dbd2e6-5ac0-4a41-84c1-48b645b4f663",
"description": "Reduce zero to lowest terms",
"property": "reduce",
"input": {
"r": [0, 6]
},
"expected": [0, 1]
},
{
"uuid": "297b45ad-2054-4874-84d4-0358dc1b8887",
"description": "Reduce an integer to lowest terms",
"property": "reduce",
"input": {
"r": [-14, 7]
},
"expected": [-2, 1]
},
{
"uuid": "a73a17fe-fe8c-4a1c-a63b-e7579e333d9e",
"description": "Reduce one to lowest terms",
"property": "reduce",
"input": {
"r": [13, 13]
},
"expected": [1, 1]
}
]
}
]
}