-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathsolution.test.js
More file actions
49 lines (31 loc) · 856 Bytes
/
solution.test.js
File metadata and controls
49 lines (31 loc) · 856 Bytes
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
const connectSticks = require('./solution')
test('Example 1', () => {
const sticks = [2, 4, 3]
const result = connectSticks(sticks)
expect(result).toBe(14)
})
test('Example 2', () => {
const sticks = [1, 8, 3, 5]
const result = connectSticks(sticks)
expect(result).toBe(30)
})
test('Only 1 stick', () => {
const sticks = [5]
const result = connectSticks(sticks)
expect(result).toBe(0)
})
test('Only 2 sticks', () => {
const sticks = [5, 4]
const result = connectSticks(sticks)
expect(result).toBe(9)
})
test('Contiguous sticks', () => {
const sticks = [3, 4, 5, 6]
const result = connectSticks(sticks)
expect(result).toBe(36)
})
test('Long sticks 2', () => {
const sticks = [3354, 4316, 3259, 4904, 4598, 474, 3166, 6322, 8080, 9009]
const result = connectSticks(sticks)
expect(result).toBe(151646)
})