Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 9528c71

Browse files
Added testcases for Zero One Knapsack (#1109)
1 parent 7a1141b commit 9528c71

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { zeroOneKnapsack } from '../ZeroOneKnapsack'
2+
3+
describe('ZeroOneKnapsack', () => {
4+
it('zeroOneKnapsack when capacity is 4 and 5 items', () => {
5+
expect(zeroOneKnapsack([[1, 8], [2, 4], [3, 0], [2, 5], [2, 3]], 5, 4, [[-1, -1, -1, -1, -1], [-1, -1, -1, -1, -1], [-1, -1, -1, -1, -1], [-1, -1, -1, -1, -1], [-1, -1, -1, -1, -1], [-1, -1, -1, -1, -1]])).toBe(13)
6+
})
7+
8+
it('zeroOneKnapsack when capacity is 1 and 1 items', () => {
9+
expect(zeroOneKnapsack([[1, 80]], 1, 1, [[-1, -1], [-1, -1]])).toBe(80)
10+
})
11+
12+
it('zeroOneKnapsack when capacity is 0 and 1 items', () => {
13+
expect(zeroOneKnapsack([[1, 80]], 1, 0, [[-1], [-1]])).toBe(0)
14+
})
15+
})

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /