-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplus-minus.test.ts
61 lines (58 loc) · 2.37 KB
/
plus-minus.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
54
55
56
57
58
59
60
61
import { Input, Output, plusMinus } from "../plus-minus";
type Cases = [Input, Output][];
describe("Plus Minus", () => {
const cases: Cases = [
[[0, 0, -1, 1, 1], "0.400000\n0.200000\n0.400000"],
[[-4, 3, -9, 0, 4, 1], "0.500000\n0.333333\n0.166667"],
[[1, -2, -7, 9, 1, -8, -5], "0.428571\n0.571429\n0.000000"],
[[0, 4, -3, 3, -6], "0.400000\n0.400000\n0.200000"],
[
[
55, 48, 48, 45, 91, 97, 45, 1, 39, 54, 36, 6, 19, 35, 66, 36, 72, 93,
38, 21, 65, 70, 36, 63, 39, 76, 82, 26, 67, 29, 24, 82, 62, 53, 1, 50,
47, 65, 67, 19, 66, 90, 77,
],
"1.000000\n0.000000\n0.000000",
],
[[0, 100, 35, 0, 94, 40, 42, 87, 59, 0], "0.700000\n0.000000\n0.300000"],
[
[
0, -67, -74, -38, -72, -53, 0, -13, -95, -91, -100, -59, 0, -10, -68,
-71, -62, -21, 0, -42, -57, -16, -66, -23, 0, -80, -63, -68, -65, -71,
0, -71, -15, -32, -26, -8, 0, -6, -51, -87, -19, -71, 0, -93, -26, -35,
-56, -89, 0, -21, -74, -39, -57, -8, 0, -69, -29, -24, -99, -53, 0, -65,
-42, -72, -18, -4, 0, -73, -46, -63, -78, -87,
],
"0.000000\n0.833333\n0.166667",
],
[
[
-92, -21, -93, -27, -45, -63, 53, 45, 0, 6, -67, 84, 96, 86, 18, 36, 53,
0, 47, 88, 91, -59, 65, 62, 3, 13, 0, -49, -47, 94, -63, 65, -23, 48,
-5, 0, -10, 67, -23, 19, -11, 46, 80, -83, 0, -40, 74, -63, -20, -72,
98, -72, 66, 0, -58, -1, 67, -22, 8, -45, 32, -65, 0, -10, -65, -81,
-36, -55, -99, -18, -82,
],
"0.408451\n0.492958\n0.098592",
],
[
[
-6, 1, 79, 17, 64, 94, 87, -77, 0, -26, 2, -94, 87, -81, -73, -28, 43,
0, -35, 39, -37, -49, -29, 93, 64, 54, 0, -73, -58, -100, 33, -75, -47,
35, -7, 0, 52, -37, -99, 58, -23, 70, -52, 18, 0, -79, -38, 45, -61, 45,
51, -48, 32, 0, -44, -56, 29, -74, -1, 92, -93, 23, 0, 55, -31, 75, -43,
20, 19, 58, -4, 0, 59, -80, 18, -74, 81, 63, 62, -92, 0, -23, 7, -91,
22, -1, 38, -73, 79, 0, -2, 90, 80, 74, -74, -85, -48, 31, 0, -80,
],
"0.440000\n0.450000\n0.110000",
],
[[1, 2, 3, -1, -2, -3, 0, 0], "0.375000\n0.375000\n0.250000"],
];
test.each(cases)(
"for given array of integers %j output should be %s",
(firstArg, expectedResult) => {
const result = plusMinus(firstArg);
expect(result.trim()).toEqual(expectedResult.trim());
}
);
});