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

Version Path
trackler-2.2.1.119 tracks/lua/exercises/change/change_spec.lua
trackler-2.2.1.118 tracks/lua/exercises/change/change_spec.lua
trackler-2.2.1.117 tracks/lua/exercises/change/change_spec.lua
trackler-2.2.1.116 tracks/lua/exercises/change/change_spec.lua
trackler-2.2.1.115 tracks/lua/exercises/change/change_spec.lua
trackler-2.2.1.114 tracks/lua/exercises/change/change_spec.lua
trackler-2.2.1.113 tracks/lua/exercises/change/change_spec.lua
trackler-2.2.1.111 tracks/lua/exercises/change/change_spec.lua
trackler-2.2.1.110 tracks/lua/exercises/change/change_spec.lua
trackler-2.2.1.109 tracks/lua/exercises/change/change_spec.lua
trackler-2.2.1.108 tracks/lua/exercises/change/change_spec.lua
trackler-2.2.1.107 tracks/lua/exercises/change/change_spec.lua
trackler-2.2.1.106 tracks/lua/exercises/change/change_spec.lua
trackler-2.2.1.105 tracks/lua/exercises/change/change_spec.lua
trackler-2.2.1.104 tracks/lua/exercises/change/change_spec.lua
trackler-2.2.1.103 tracks/lua/exercises/change/change_spec.lua
trackler-2.2.1.102 tracks/lua/exercises/change/change_spec.lua
trackler-2.2.1.101 tracks/lua/exercises/change/change_spec.lua
trackler-2.2.1.100 tracks/lua/exercises/change/change_spec.lua
trackler-2.2.1.99 tracks/lua/exercises/change/change_spec.lua