Skip to content

Commit fb2c0bb

Browse files
author
Jakub Jirous
authored
Merge pull request #6 from jakubjirous/feature/index
Index.md
2 parents 34dc95c + 9cecef2 commit fb2c0bb

File tree

5 files changed

+164
-14
lines changed

5 files changed

+164
-14
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ Developers compete by writing programs according to provided specifications.
2222

2323
### Preparation Kit
2424

25-
1. [Plus Minus](/src/challenges/01-plus-minus/)
26-
2. [Mini-Max Sum](/src/challenges/02-mini-max-sum/)
27-
3. [Time Conversion](/src/challenges/03-time-conversion/)
25+
1. [Plus Minus](/src/challenges/01-plus-minus/INDEX.md)
26+
2. [Mini-Max Sum](/src/challenges/02-mini-max-sum/INDEX.md)
27+
3. [Time Conversion](/src/challenges/03-time-conversion/INDEX.md)
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# Plus Minus
2+
3+
Given an array of integers, calculate the ratios of its elements that are positive, negative, and zero.
4+
5+
Print the decimal value of each fraction on a new line with `6` places after the decimal.
6+
7+
---
8+
9+
### Note:
10+
11+
This challenge introduces precision problems. The test cases are scaled to six decimal places, though answers with absolute error of up to $10^{-1}$ are acceptable.
12+
13+
### Example:
14+
15+
- `inputArray = [1, 1, 0, -1, -1]`
16+
- There are `n = 5` elements, two positive, two negative and one zero. Their ratios are $\frac{2}{5} = 0.400000$, $\frac{2}{5} = 0.400000$ and $\frac{1}{5} = 0.200000$.
17+
- Results are printed as:
18+
- `0.40000`
19+
- `0.40000`
20+
- `0.20000`
21+
22+
### Function Description:
23+
24+
- Complete the plusMinus function in the editor below.
25+
- `plusMinus` has the following parameter(s):
26+
- `inputArray[n]`: an array of integers
27+
28+
### Print:
29+
30+
- Print the ratios of positive, negative and zero values in the array.
31+
- Each value should be printed on a separate line with digits after the decimal.
32+
- The function should not return a value.
33+
34+
### Input Format:
35+
36+
- The first line contains an integer, `n`, the size of the array.
37+
- The second line contains `n` space-separated integers that describe `inputArray[n]`.
38+
39+
### Constraints:
40+
41+
- $0 \le n \le 100$
42+
- $-100 \le inputArray[i] \le 100$
43+
44+
### Output Format:
45+
46+
- Print the following `3` lines, each to `6` decimals:
47+
48+
1) proportion of positive values
49+
2) proportion of negative values
50+
3) proportion of zeros
51+
52+
---
53+
54+
### Sample Input:
55+
56+
```
57+
STDIN Function
58+
----- --------
59+
6 inputArray[] size n = 6
60+
-4 3 -9 0 4 1 inputArray = [-4, 3, -9, 0, 4, 1]
61+
```
62+
63+
### Sample Output:
64+
65+
```
66+
0.500000
67+
0.333333
68+
0.166667
69+
```
70+
71+
### Explanation:
72+
73+
- There are `3` positive numbers, `2` negative numbers, and `1` zero in the array.
74+
- The proportions of occurrence are:
75+
- positive: $\frac{3}{6} = 0.500000$
76+
- negative: $\frac{2}{6} = 0.333333$
77+
- zeros: $\frac{1}{6} = 0.166667$
78+
79+
---
80+
81+
### Solution:
82+
83+
- [Code](/src/challenges/01-plus-minus/plus-minus.ts)
84+
- [Tests](/src/challenges/01-plus-minus/test/plus-minus.test.ts)
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# Mini-Max Sum
2+
3+
Given five positive integers, find the minimum and maximum values that can be calculated by summing exactly four of the five integers. Then print the respective minimum and maximum values as a single line of two space-separated long integers.
4+
5+
---
6+
7+
### Example:
8+
9+
- `inputArray = [1, 3, 5, 7, 9]`
10+
- The minimum sum is `1 + 3 + 5 + 7 = 16` and the maximum sum is `3 + 5 + 7 + 9 = 24`.
11+
- The function prints `16 24`
12+
13+
### Function Description:
14+
15+
- Complete the miniMaxSum function in the editor below.
16+
- `miniMaxSum` has the following parameter(s):
17+
- `inputArray`: an array of `5` integers
18+
19+
### Print:
20+
21+
- Print two space-separated integers on one line: the minimum sum and the maximum sum of `4` of `5` elements.
22+
23+
### Input Format:
24+
25+
- A single line of five space-separated integers.
26+
27+
### Constraints:
28+
29+
- $1 \le inputArray[i] \le 10^9$
30+
31+
### Output Format:
32+
33+
- Print two space-separated long integers denoting the respective minimum and maximum values that can be calculated by summing exactly four of the five integers.
34+
- The output can be greater than a 32-bit integer.
35+
36+
37+
---
38+
39+
### Sample Input:
40+
41+
```
42+
1 2 3 4 5
43+
```
44+
45+
### Sample Output:
46+
47+
```
48+
10 14
49+
```
50+
51+
### Explanation:
52+
53+
The numbers are `1, 2, 3, 4,` and `5`.
54+
55+
Calculate the following sums using four of the five integers:
56+
57+
1) Sum everything except `1`, the sum is `2 + 3 + 4 + 5 = 14`.
58+
2) Sum everything except `2`, the sum is `1 + 3 + 4 + 5 = 13`.
59+
3) Sum everything except `3`, the sum is `1 + 2 + 4 + 5 = 12`.
60+
4) Sum everything except `4`, the sum is `1 + 2 + 3 + 5 = 11`.
61+
5) Sum everything except `5`, the sum is `1 + 2 + 3 + 4 = 10`.
62+
63+
---
64+
65+
### Solution:
66+
67+
- [Code](/src/challenges/02-mini-max-sum/mini-max-sum.ts)
68+
- [Tests](/src/challenges/02-mini-max-sum/test/mini-max-sum.test.ts)

src/challenges/02-mini-max-sum/mini-max-sum.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,9 @@ export type Output = [number, number];
55
* Given five positive integers, find the minimum and maximum values that can be calculated by summing exactly four of the five integers. Then
66
* print the respective minimum and maximum values as a single line of two space-separated long integers.
77
*
8-
* Explanation:
9-
* - The numbers are 1, 2, 3, 4, and 5.
10-
* - Calculate the following sums using four of the five integers:
11-
* - 1) Sum everything except 1, the sum is 2 + 3 + 4 + 5 = 14.
12-
* - 2) Sum everything except 2, the sum is 1 + 3 + 4 + 5 = 13.
13-
* - 3) Sum everything except 3, the sum is 1 + 2 + 4 + 5 = 12.
14-
* - 4) Sum everything except 4, the sum is 1 + 2 + 3 + 5 = 11.
15-
* - 5) Sum everything except 5, the sum is 1 + 2 + 3 + 4 = 10.
16-
*
178
* Output Format:
189
* - Print two space-separated long integers denoting the respective minimum and maximum values that can be calculated by summing exactly four of the five integers.
19-
* - The output can be greater than a 32 bit integer.
10+
* - The output can be greater than a 32-bit integer.
2011
*
2112
* Example:
2213
* - inputArray = [1, 3, 5, 7, 9]

src/challenges/03-time-conversion/INDEX.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Given a time in 12-hour AM/PM format, convert it to military (24-hour) time.
1717

1818
### Function Description:
1919

20-
- Complete the `timeConversion` function in the editor below. It should return a new string representing the input time in 24 hour format.
20+
- Complete the `timeConversion` function in the editor below. It should return a new string representing the input time in 24-hour format.
2121

2222
- `timeConversion` has the following parameter(`s`):
2323
- string `s`: a time in 12-hour format
@@ -47,3 +47,10 @@ Given a time in 12-hour AM/PM format, convert it to military (24-hour) time.
4747
```
4848
19:05:45
4949
```
50+
51+
---
52+
53+
### Solution:
54+
55+
- [Code](/src/challenges/03-time-conversion/time-conversion.ts)
56+
- [Tests](/src/challenges/03-time-conversion/test/time-conversion.test.ts)

0 commit comments

Comments
 (0)