|
1 | | -import { change } from '../CoinChange' |
| 1 | +import { change, coinChangeMin } from '../CoinChange' |
2 | 2 |
|
3 | 3 | test('Base Case 1', () => { |
4 | 4 | const coins = [2, 3, 5] |
5 | 5 | const amount = 0 |
6 | 6 | expect(change(coins, amount)).toBe(1) |
| 7 | + expect(coinChangeMin(coins, amount)).toBe(0) |
7 | 8 | }) |
8 | 9 | test('Base Case 2', () => { |
9 | 10 | const coins = [] |
10 | 11 | const amount = 100 |
11 | 12 | expect(change(coins, amount)).toBe(0) |
| 13 | + expect(coinChangeMin(coins, amount)).toBe(-1) |
12 | 14 | }) |
13 | 15 | test('Test Case 1', () => { |
14 | 16 | const coins = [2, 4, 5] |
15 | 17 | const amount = 12 |
16 | 18 | expect(change(coins, amount)).toBe(5) |
| 19 | + expect(coinChangeMin(coins, amount)).toBe(3) |
17 | 20 | }) |
18 | 21 | test('Test Case 2', () => { |
19 | 22 | const coins = [5, 2, 3, 7, 6, 1, 12, 11, 9, 15] |
20 | 23 | const amount = 45 |
21 | 24 | expect(change(coins, amount)).toBe(12372) |
| 25 | + expect(coinChangeMin(coins, amount)).toBe(3) |
22 | 26 | }) |
23 | 27 | test('Test Case 3', () => { |
24 | 28 | const coins = [2] |
25 | 29 | const amount = 3 |
26 | 30 | expect(change(coins, amount)).toBe(0) |
| 31 | + expect(coinChangeMin(coins, amount)).toBe(-1) |
27 | 32 | }) |
28 | 33 | test('Test Case 4', () => { |
29 | 34 | const coins = [3, 5, 7, 8, 9, 10, 11] |
30 | 35 | const amount = 500 |
31 | 36 | expect(change(coins, amount)).toBe(35502874) |
| 37 | + expect(coinChangeMin(coins, amount)).toBe(46) |
32 | 38 | }) |
33 | 39 | test('Test Case 5', () => { |
34 | 40 | const coins = [10] |
35 | 41 | const amount = 10 |
36 | 42 | expect(change(coins, amount)).toBe(1) |
| 43 | + expect(coinChangeMin(coins, amount)).toBe(1) |
37 | 44 | }) |
0 commit comments