Skip to content

Commit 60095e4

Browse files
authored
Improved tasks 2624-2629
1 parent f82f120 commit 60095e4

File tree

5 files changed

+29
-18
lines changed

5 files changed

+29
-18
lines changed

src/main/java/g2601_2700/s2629_function_composition/solution.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// #Easy #2023_08_31_Time_58_ms_(95.63%)_Space_45.3_MB_(73.06%)
22

3-
type F = (x: number) => number;
3+
type F = (x: number) => number
44

55
function compose(functions: F[]): F {
66
return function (x) {

src/test/java/g2601_2700/s2624_snail_traversal/solution.test.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,25 @@ import 'src/main/java/g2601_2700/s2624_snail_traversal/solution'
33
import { expect, test } from 'vitest'
44

55
test('snail', () => {
6-
let nums = [19, 10, 3, 7, 9, 8, 5, 2, 1, 17, 16, 14, 12, 18, 6, 13, 11, 20, 4, 15].snail(5,4)
6+
let nums = [19, 10, 3, 7, 9, 8, 5, 2, 1, 17, 16, 14, 12, 18, 6, 13, 11, 20, 4, 15].snail(5, 4)
77
let result = [
8-
[19,17,16,15],
9-
[10,1,14,4],
10-
[3,2,12,20],
11-
[7,5,18,11],
12-
[9,8,6,13]
13-
]
8+
[19, 17, 16, 15],
9+
[10, 1, 14, 4],
10+
[3, 2, 12, 20],
11+
[7, 5, 18, 11],
12+
[9, 8, 6, 13],
13+
]
1414
expect(nums).toEqual(result)
1515
})
1616

1717
test('snail2', () => {
18-
let nums = [1,2,3,4].snail(1,4)
18+
let nums = [1, 2, 3, 4].snail(1, 4)
1919
let result = [[1, 2, 3, 4]]
2020
expect(nums).toEqual(result)
2121
})
2222

2323
test('snail3', () => {
24-
let nums = [1,3].snail(2,2)
24+
let nums = [1, 3].snail(2, 2)
2525
let result = []
2626
expect(nums).toEqual(result)
2727
})

src/test/java/g2601_2700/s2625_flatten_deeply_nested_array/solution.test.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,12 @@ test('flat2', () => {
1717
})
1818

1919
test('flat3', () => {
20-
let arr = [[1, 2, 3], [4, 5, 6], [7, 8, [9, 10, 11], 12], [13, 14, 15]]
20+
let arr = [
21+
[1, 2, 3],
22+
[4, 5, 6],
23+
[7, 8, [9, 10, 11], 12],
24+
[13, 14, 15],
25+
]
2126
let n = 2
2227
let result = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
2328
expect(flat(arr, n)).toEqual(result)

src/test/java/g2601_2700/s2626_array_reduce_transformation/solution.test.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,28 @@ import { reduce } from 'src/main/java/g2601_2700/s2626_array_reduce_transformati
33
import { expect, test } from 'vitest'
44

55
test('reduce', () => {
6-
let nums = [1,2,3,4]
7-
let fn = function sum(accum, curr) { return accum + curr; }
6+
let nums = [1, 2, 3, 4]
7+
let fn = function sum(accum, curr) {
8+
return accum + curr
9+
}
810
let init = 0
911
expect(reduce(nums, fn, init)).toEqual(10)
1012
})
1113

1214
test('reduce2', () => {
13-
let nums = [1,2,3,4]
14-
let fn = function sum(accum, curr) { return accum + curr * curr; }
15+
let nums = [1, 2, 3, 4]
16+
let fn = function sum(accum, curr) {
17+
return accum + curr * curr
18+
}
1519
let init = 100
1620
expect(reduce(nums, fn, init)).toEqual(130)
1721
})
1822

1923
test('reduce3', () => {
2024
let nums = []
21-
let fn = function sum(accum, curr) { return 0; }
25+
let fn = function sum(accum, curr) {
26+
return 0
27+
}
2228
let init = 25
2329
expect(reduce(nums, fn, init)).toEqual(25)
2430
})

src/test/java/g2601_2700/s2629_function_composition/solution.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ import { compose } from 'src/main/java/g2601_2700/s2629_function_composition/sol
33
import { expect, test } from 'vitest'
44

55
test('compose', () => {
6-
let functions = [x => x + 1, x => x * x, x => 2 * x]
6+
let functions = [(x) => x + 1, (x) => x * x, (x) => 2 * x]
77
let x = 4
88
const fn = compose(functions)
99
expect(fn(x)).toEqual(65)
1010
})
1111

1212
test('compose2', () => {
13-
let functions = [x => 10 * x, x => 10 * x, x => 10 * x]
13+
let functions = [(x) => 10 * x, (x) => 10 * x, (x) => 10 * x]
1414
let x = 1
1515
const fn = compose(functions)
1616
expect(fn(x)).toEqual(1000)

0 commit comments

Comments
 (0)