Select Git revision
makeChange.test.js
Forked from
SOFT Core / SOFT 260 / Dynamic Programming Lab
Source project has a limited visibility.
makeChange.test.js 14.47 KiB
/* eslint-disable no-magic-numbers */
import { makeChange } from './makeChange.js';
describe('makeChange makes change using the fewest possible number of coins', () => {
test('when the amount is 7¢ and the coins are {1¢, 3¢, 4¢, 5¢}', () => {
expect(makeChange([1, 3, 4, 5], 7)).toEqual([4, 3]);
});
test('when the amount is 8¢ and the coins are {1¢, 2¢, 4¢, 5¢}', () => {
expect(makeChange([1, 2, 4, 5], 8)).toEqual([4, 4]);
});
test('when the amount is 8¢ and the coins are {1¢, 3¢, 4¢, 6¢}', () => {
expect(makeChange([1, 3, 4, 6], 8)).toEqual([4, 4]);
});
test('when the amount is 8¢ and the coins are {1¢, 3¢, 5¢, 6¢}', () => {
expect(makeChange([1, 3, 5, 6], 8)).toEqual([5, 3]);
});
test('when the amount is 8¢ and the coins are {1¢, 4¢, 5¢, 6¢}', () => {
expect(makeChange([1, 4, 5, 6], 8)).toEqual([4, 4]);
});
test('when the amount is 9¢ and the coins are {1¢, 3¢, 6¢, 7¢}', () => {
expect(makeChange([1, 3, 6, 7], 9)).toEqual([6, 3]);
});
test('when the amount is 9¢ and the coins are {1¢, 4¢, 5¢, 6¢}', () => {
expect(makeChange([1, 4, 5, 6], 9)).toEqual([5, 4]);
});
test('when the amount is 9¢ and the coins are {1¢, 4¢, 5¢, 7¢}', () => {
expect(makeChange([1, 4, 5, 7], 9)).toEqual([5, 4]);
});
test('when the amount is 10¢ and the coins are {1¢, 2¢, 5¢, 6¢}', () => {
expect(makeChange([1, 2, 5, 6], 10)).toEqual([5, 5]);
});
test('when the amount is 10¢ and the coins are {1¢, 2¢, 5¢, 7¢}', () => {
expect(makeChange([1, 2, 5, 7], 10)).toEqual([5, 5]);
});
test('when the amount is 10¢ and the coins are {1¢, 3¢, 5¢, 6¢}', () => {
expect(makeChange([1, 3, 5, 6], 10)).toEqual([5, 5]);
});
test('when the amount is 10¢ and the coins are {1¢, 3¢, 5¢, 8¢}', () => {
expect(makeChange([1, 3, 5, 8], 10)).toEqual([5, 5]);
});
test('when the amount is 10¢ and the coins are {1¢, 3¢, 7¢, 8¢}', () => {
expect(makeChange([1, 3, 7, 8], 10)).toEqual([7, 3]);
});
test('when the amount is 10¢ and the coins are {1¢, 4¢, 5¢, 7¢}', () => {
expect(makeChange([1, 4, 5, 7], 10)).toEqual([5, 5]);
});
test('when the amount is 10¢ and the coins are {1¢, 4¢, 5¢, 8¢}', () => {
expect(makeChange([1, 4, 5, 8], 10)).toEqual([5, 5]);
});
test('when the amount is 10¢ and the coins are {1¢, 4¢, 6¢, 7¢}', () => {
expect(makeChange([1, 4, 6, 7], 10)).toEqual([6, 4]);
});
test('when the amount is 10¢ and the coins are {1¢, 4¢, 6¢, 8¢}', () => {
expect(makeChange([1, 4, 6, 8], 10)).toEqual([6, 4]);
});
test('when the amount is 10¢ and the coins are {1¢, 5¢, 6¢, 7¢}', () => {
expect(makeChange([1, 5, 6, 7], 10)).toEqual([5, 5]);
});
test('when the amount is 10¢ and the coins are {1¢, 5¢, 6¢, 8¢}', () => {
expect(makeChange([1, 5, 6, 8], 10)).toEqual([5, 5]);
});
test('when the amount is 10¢ and the coins are {1¢, 5¢, 7¢, 8¢}', () => {
expect(makeChange([1, 5, 7, 8], 10)).toEqual([5, 5]);
});
test('when the amount is 11¢ and the coins are {1¢, 2¢, 5¢, 7¢}', () => {
expect(makeChange([1, 2, 5, 7], 11)).toEqual([5, 5, 1]);
});
test('when the amount is 11¢ and the coins are {1¢, 3¢, 8¢, 9¢}', () => {
expect(makeChange([1, 3, 8, 9], 11)).toEqual([8, 3]);
});
test('when the amount is 11¢ and the coins are {1¢, 4¢, 5¢, 8¢}', () => {
expect(makeChange([1, 4, 5, 8], 11)).toEqual([5, 5, 1]);
});
test('when the amount is 11¢ and the coins are {1¢, 4¢, 6¢, 8¢}', () => {
expect(makeChange([1, 4, 6, 8], 11)).toEqual([6, 4, 1]);
});
test('when the amount is 11¢ and the coins are {1¢, 4¢, 7¢, 8¢}', () => {
expect(makeChange([1, 4, 7, 8], 11)).toEqual([7, 4]);
});
test('when the amount is 11¢ and the coins are {1¢, 4¢, 7¢, 9¢}', () => {
expect(makeChange([1, 4, 7, 9], 11)).toEqual([7, 4]);
});
test('when the amount is 11¢ and the coins are {1¢, 5¢, 6¢, 7¢}', () => {
expect(makeChange([1, 5, 6, 7], 11)).toEqual([6, 5]);
});
test('when the amount is 11¢ and the coins are {1¢, 5¢, 6¢, 8¢}', () => {
expect(makeChange([1, 5, 6, 8], 11)).toEqual([6, 5]);
});
test('when the amount is 11¢ and the coins are {1¢, 5¢, 6¢, 9¢}', () => {
expect(makeChange([1, 5, 6, 9], 11)).toEqual([6, 5]);
});
test('when the amount is 11¢ and the coins are {1¢, 5¢, 7¢, 8¢}', () => {
expect(makeChange([1, 5, 7, 8], 11)).toEqual([5, 5, 1]);
});
test('when the amount is 12¢ and the coins are {1¢, 2¢, 6¢, 7¢}', () => {
expect(makeChange([1, 2, 6, 7], 12)).toEqual([6, 6]);
});
test('when the amount is 12¢ and the coins are {1¢, 2¢, 6¢, 8¢}', () => {
expect(makeChange([1, 2, 6, 8], 12)).toEqual([6, 6]);
});
test('when the amount is 12¢ and the coins are {1¢, 2¢, 6¢, 9¢}', () => {
expect(makeChange([1, 2, 6, 9], 12)).toEqual([6, 6]);
});
test('when the amount is 12¢ and the coins are {1¢, 3¢, 4¢, 5¢}', () => {
expect(makeChange([1, 3, 4, 5], 12)).toEqual([5, 4, 3]);
});
test('when the amount is 12¢ and the coins are {1¢, 3¢, 6¢, 7¢}', () => {
expect(makeChange([1, 3, 6, 7], 12)).toEqual([6, 6]);
});
test('when the amount is 12¢ and the coins are {1¢, 3¢, 6¢, 8¢}', () => {
expect(makeChange([1, 3, 6, 8], 12)).toEqual([6, 6]);
});
test('when the amount is 12¢ and the coins are {1¢, 3¢, 6¢, 10¢}', () => {
expect(makeChange([1, 3, 6, 10], 12)).toEqual([6, 6]);
});
test('when the amount is 12¢ and the coins are {1¢, 3¢, 9¢, 10¢}', () => {
expect(makeChange([1, 3, 9, 10], 12)).toEqual([9, 3]);
});
test('when the amount is 12¢ and the coins are {1¢, 4¢, 5¢, 9¢}', () => {
expect(makeChange([1, 4, 5, 9], 12)).toEqual([4, 4, 4]);
});
test('when the amount is 12¢ and the coins are {1¢, 4¢, 6¢, 7¢}', () => {
expect(makeChange([1, 4, 6, 7], 12)).toEqual([6, 6]);
});
test('when the amount is 12¢ and the coins are {1¢, 4¢, 6¢, 9¢}', () => {
expect(makeChange([1, 4, 6, 9], 12)).toEqual([6, 6]);
});
test('when the amount is 12¢ and the coins are {1¢, 4¢, 6¢, 10¢}', () => {
expect(makeChange([1, 4, 6, 10], 12)).toEqual([6, 6]);
});
test('when the amount is 12¢ and the coins are {1¢, 4¢, 7¢, 9¢}', () => {
expect(makeChange([1, 4, 7, 9], 12)).toEqual([7, 4, 1]);
});
test('when the amount is 12¢ and the coins are {1¢, 4¢, 8¢, 9¢}', () => {
expect(makeChange([1, 4, 8, 9], 12)).toEqual([8, 4]);
});
test('when the amount is 12¢ and the coins are {1¢, 4¢, 8¢, 10¢}', () => {
expect(makeChange([1, 4, 8, 10], 12)).toEqual([8, 4]);
});
test('when the amount is 12¢ and the coins are {1¢, 5¢, 6¢, 8¢}', () => {
expect(makeChange([1, 5, 6, 8], 12)).toEqual([6, 6]);
});
test('when the amount is 12¢ and the coins are {1¢, 5¢, 6¢, 9¢}', () => {
expect(makeChange([1, 5, 6, 9], 12)).toEqual([6, 6]);
});
test('when the amount is 12¢ and the coins are {1¢, 5¢, 6¢, 10¢}', () => {
expect(makeChange([1, 5, 6, 10], 12)).toEqual([6, 6]);
});
test('when the amount is 12¢ and the coins are {1¢, 5¢, 7¢, 8¢}', () => {
expect(makeChange([1, 5, 7, 8], 12)).toEqual([7, 5]);
});
test('when the amount is 12¢ and the coins are {1¢, 5¢, 7¢, 9¢}', () => {
expect(makeChange([1, 5, 7, 9], 12)).toEqual([7, 5]);
});
test('when the amount is 12¢ and the coins are {1¢, 5¢, 7¢, 10¢}', () => {
expect(makeChange([1, 5, 7, 10], 12)).toEqual([7, 5]);
});
test('when the amount is 12¢ and the coins are {1¢, 6¢, 7¢, 8¢}', () => {
expect(makeChange([1, 6, 7, 8], 12)).toEqual([6, 6]);
});
test('when the amount is 12¢ and the coins are {1¢, 6¢, 7¢, 9¢}', () => {
expect(makeChange([1, 6, 7, 9], 12)).toEqual([6, 6]);
});
test('when the amount is 12¢ and the coins are {1¢, 6¢, 7¢, 10¢}', () => {
expect(makeChange([1, 6, 7, 10], 12)).toEqual([6, 6]);
});
test('when the amount is 12¢ and the coins are {1¢, 6¢, 8¢, 9¢}', () => {
expect(makeChange([1, 6, 8, 9], 12)).toEqual([6, 6]);
});
test('when the amount is 12¢ and the coins are {1¢, 6¢, 8¢, 10¢}', () => {
expect(makeChange([1, 6, 8, 10], 12)).toEqual([6, 6]);
});
test('when the amount is 12¢ and the coins are {1¢, 6¢, 9¢, 10¢}', () => {
expect(makeChange([1, 6, 9, 10], 12)).toEqual([6, 6]);
});
test('when the amount is 13¢ and the coins are {1¢, 2¢, 4¢, 5¢}', () => {
expect(makeChange([1, 2, 4, 5], 13)).toEqual([5, 4, 4]);
});
test('when the amount is 13¢ and the coins are {1¢, 2¢, 6¢, 8¢}', () => {
expect(makeChange([1, 2, 6, 8], 13)).toEqual([6, 6, 1]);
});
test('when the amount is 13¢ and the coins are {1¢, 2¢, 6¢, 9¢}', () => {
expect(makeChange([1, 2, 6, 9], 13)).toEqual([6, 6, 1]);
});
test('when the amount is 13¢ and the coins are {1¢, 3¢, 4¢, 7¢}', () => {
expect(makeChange([1, 3, 4, 7], 13)).toEqual([7, 3, 3]);
});
test('when the amount is 13¢ and the coins are {1¢, 3¢, 6¢, 8¢}', () => {
expect(makeChange([1, 3, 6, 8], 13)).toEqual([6, 6, 1]);
});
test('when the amount is 13¢ and the coins are {1¢, 3¢, 7¢, 8¢}', () => {
expect(makeChange([1, 3, 7, 8], 13)).toEqual([7, 3, 3]);
});
test('when the amount is 13¢ and the coins are {1¢, 3¢, 10¢, 11¢}', () => {
expect(makeChange([1, 3, 10, 11], 13)).toEqual([10, 3]);
});
test('when the amount is 13¢ and the coins are {1¢, 4¢, 5¢, 10¢}', () => {
expect(makeChange([1, 4, 5, 10], 13)).toEqual([5, 4, 4]);
});
test('when the amount is 13¢ and the coins are {1¢, 4¢, 6¢, 10¢}', () => {
expect(makeChange([1, 4, 6, 10], 13)).toEqual([6, 6, 1]);
});
test('when the amount is 13¢ and the coins are {1¢, 4¢, 8¢, 10¢}', () => {
expect(makeChange([1, 4, 8, 10], 13)).toEqual([8, 4, 1]);
});
test('when the amount is 13¢ and the coins are {1¢, 4¢, 9¢, 10¢}', () => {
expect(makeChange([1, 4, 9, 10], 13)).toEqual([9, 4]);
});
test('when the amount is 13¢ and the coins are {1¢, 4¢, 9¢, 11¢}', () => {
expect(makeChange([1, 4, 9, 11], 13)).toEqual([9, 4]);
});
test('when the amount is 13¢ and the coins are {1¢, 5¢, 6¢, 9¢}', () => {
expect(makeChange([1, 5, 6, 9], 13)).toEqual([6, 6, 1]);
});
test('when the amount is 13¢ and the coins are {1¢, 5¢, 6¢, 10¢}', () => {
expect(makeChange([1, 5, 6, 10], 13)).toEqual([6, 6, 1]);
});
test('when the amount is 13¢ and the coins are {1¢, 5¢, 7¢, 9¢}', () => {
expect(makeChange([1, 5, 7, 9], 13)).toEqual([7, 5, 1]);
});
test('when the amount is 13¢ and the coins are {1¢, 5¢, 7¢, 10¢}', () => {
expect(makeChange([1, 5, 7, 10], 13)).toEqual([7, 5, 1]);
});
test('when the amount is 13¢ and the coins are {1¢, 5¢, 8¢, 9¢}', () => {
expect(makeChange([1, 5, 8, 9], 13)).toEqual([8, 5]);
});
test('when the amount is 13¢ and the coins are {1¢, 5¢, 8¢, 10¢}', () => {
expect(makeChange([1, 5, 8, 10], 13)).toEqual([8, 5]);
});
test('when the amount is 13¢ and the coins are {1¢, 5¢, 8¢, 11¢}', () => {
expect(makeChange([1, 5, 8, 11], 13)).toEqual([8, 5]);
});
test('when the amount is 13¢ and the coins are {1¢, 6¢, 7¢, 8¢}', () => {
expect(makeChange([1, 6, 7, 8], 13)).toEqual([7, 6]);
});
test('when the amount is 13¢ and the coins are {1¢, 6¢, 7¢, 9¢}', () => {
expect(makeChange([1, 6, 7, 9], 13)).toEqual([7, 6]);
});
test('when the amount is 13¢ and the coins are {1¢, 6¢, 7¢, 10¢}', () => {
expect(makeChange([1, 6, 7, 10], 13)).toEqual([7, 6]);
});
test('when the amount is 13¢ and the coins are {1¢, 6¢, 7¢, 11¢}', () => {
expect(makeChange([1, 6, 7, 11], 13)).toEqual([7, 6]);
});
test('when the amount is 13¢ and the coins are {1¢, 6¢, 8¢, 9¢}', () => {
expect(makeChange([1, 6, 8, 9], 13)).toEqual([6, 6, 1]);
});
test('when the amount is 13¢ and the coins are {1¢, 6¢, 8¢, 10¢}', () => {
expect(makeChange([1, 6, 8, 10], 13)).toEqual([6, 6, 1]);
});
test('when the amount is 13¢ and the coins are {1¢, 6¢, 9¢, 10¢}', () => {
expect(makeChange([1, 6, 9, 10], 13)).toEqual([6, 6, 1]);
});
test('when the amount is 14¢ and the coins are {1¢, 2¢, 6¢, 9¢}', () => {
expect(makeChange([1, 2, 6, 9], 14)).toEqual([6, 6, 2]);
});
test('when the amount is 14¢ and the coins are {1¢, 2¢, 7¢, 8¢}', () => {
expect(makeChange([1, 2, 7, 8], 14)).toEqual([7, 7]);
});
test('when the amount is 14¢ and the coins are {1¢, 2¢, 7¢, 9¢}', () => {
expect(makeChange([1, 2, 7, 9], 14)).toEqual([7, 7]);
});
test('when the amount is 14¢ and the coins are {1¢, 2¢, 7¢, 10¢}', () => {
expect(makeChange([1, 2, 7, 10], 14)).toEqual([7, 7]);
});
test('when the amount is 14¢ and the coins are {1¢, 2¢, 7¢, 11¢}', () => {
expect(makeChange([1, 2, 7, 11], 14)).toEqual([7, 7]);
});
test('when the amount is 14¢ and the coins are {1¢, 3¢, 4¢, 6¢}', () => {
expect(makeChange([1, 3, 4, 6], 14)).toEqual([6, 4, 4]);
});
test('when the amount is 14¢ and the coins are {1¢, 3¢, 4¢, 8¢}', () => {
expect(makeChange([1, 3, 4, 8], 14)).toEqual([8, 3, 3]);
});
test('when the amount is 14¢ and the coins are {1¢, 3¢, 5¢, 6¢}', () => {
expect(makeChange([1, 3, 5, 6], 14)).toEqual([6, 5, 3]);
});
test('when the amount is 14¢ and the coins are {1¢, 3¢, 7¢, 8¢}', () => {
expect(makeChange([1, 3, 7, 8], 14)).toEqual([7, 7]);
});
test('when the amount is 14¢ and the coins are {1¢, 3¢, 7¢, 9¢}', () => {
expect(makeChange([1, 3, 7, 9], 14)).toEqual([7, 7]);
});
test('when the amount is 14¢ and the coins are {1¢, 3¢, 7¢, 10¢}', () => {
expect(makeChange([1, 3, 7, 10], 14)).toEqual([7, 7]);
});
test('when the amount is 14¢ and the coins are {1¢, 3¢, 7¢, 12¢}', () => {
expect(makeChange([1, 3, 7, 12], 14)).toEqual([7, 7]);
});
test('when the amount is 14¢ and the coins are {1¢, 3¢, 8¢, 9¢}', () => {
expect(makeChange([1, 3, 8, 9], 14)).toEqual([8, 3, 3]);
});
test('when the amount is 14¢ and the coins are {1¢, 3¢, 11¢, 12¢}', () => {
expect(makeChange([1, 3, 11, 12], 14)).toEqual([11, 3]);
});
test('when the amount is 14¢ and the coins are {1¢, 4¢, 5¢, 6¢}', () => {
expect(makeChange([1, 4, 5, 6], 14)).toEqual([6, 4, 4]);
});
test('when the amount is 14¢ and the coins are {1¢, 4¢, 5¢, 11¢}', () => {
expect(makeChange([1, 4, 5, 11], 14)).toEqual([5, 5, 4]);
});
test('when the amount is 14¢ and the coins are {1¢, 4¢, 6¢, 11¢}', () => {
expect(makeChange([1, 4, 6, 11], 14)).toEqual([6, 4, 4]);
});
});