Sha256: a36ef6eb003725ec0f42ada87a818f6c7d7bff1591a69e69e018c9249e07e89c
Contents?: true
Size: 994 Bytes
Versions: 396
Compression:
Stored size: 994 Bytes
Contents
local change = require('change') describe('change', function() it('should generate the correct change when there is only one type of coin', function() assert.same({ 5 }, change(5, { 1 })) end) it('should generate the correct change when there are multiple coin types', function() assert.same({ 5, 0 }, change(5, { 1, 10 })) end) it('should generate the correct change when multiple types of coins are needed', function() assert.same({ 3, 1, 1 }, change(18, { 1, 5, 10 })) end) it('should return nil if it is not possible to make change', function() assert.is_nil(change(3, { 5, 10, 25 })) end) it('should generate the correct change given any coin order', function() assert.same({ 3, 1, 1 }, change(18, { 1, 5, 10 })) assert.same({ 1, 1, 3 }, change(18, { 10, 5, 1 })) end) it('should generate the correct change for large values with many coins', function() assert.same({ 3, 1, 0, 1, 1 }, change(133, { 1, 5, 10, 25, 100 })) end) end)
Version data entries
396 entries across 396 versions & 1 rubygems