Skip to content

Commit e03e580

Browse files
committed
feat: 添加分桌子算法题
1 parent d4ff039 commit e03e580

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
const { check, checkMem } = require('../index');
2+
describe('分桌坐 ', () => {
3+
describe('递归解法', () => {
4+
it('6人 每桌最少坐2人 4种分法', () => {
5+
expect(check(6, 2, 10)).toBe(4);
6+
})
7+
it('10人 每桌最少坐2人 12种分法', () => {
8+
expect(check(10, 2, 10)).toBe(12);
9+
})
10+
it('100人 每桌最少坐2人 437420种分法', () => {
11+
expect(check(100, 2, 10)).toBe(437420);
12+
})
13+
})
14+
15+
describe('递归解法 + 内存化', () => {
16+
it('6人 每桌最少坐2人 4种分法', () => {
17+
expect(checkMem(6, 2, 10)).toBe(4);
18+
})
19+
it('10人 每桌最少坐2人 12种分法', () => {
20+
expect(checkMem(10, 2, 10)).toBe(12);
21+
})
22+
it('100人 每桌最少坐2人 437420种分法', () => {
23+
expect(checkMem(100, 2, 10)).toBe(437420);
24+
})
25+
})
26+
})

0 commit comments

Comments
 (0)