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.180 tracks/lua/exercises/change/change_spec.lua
trackler-2.2.1.179 tracks/lua/exercises/change/change_spec.lua
trackler-2.2.1.178 tracks/lua/exercises/change/change_spec.lua
trackler-2.2.1.177 tracks/lua/exercises/change/change_spec.lua
trackler-2.2.1.176 tracks/lua/exercises/change/change_spec.lua
trackler-2.2.1.175 tracks/lua/exercises/change/change_spec.lua
trackler-2.2.1.174 tracks/lua/exercises/change/change_spec.lua
trackler-2.2.1.173 tracks/lua/exercises/change/change_spec.lua
trackler-2.2.1.172 tracks/lua/exercises/change/change_spec.lua
trackler-2.2.1.171 tracks/lua/exercises/change/change_spec.lua
trackler-2.2.1.170 tracks/lua/exercises/change/change_spec.lua
trackler-2.2.1.169 tracks/lua/exercises/change/change_spec.lua
trackler-2.2.1.167 tracks/lua/exercises/change/change_spec.lua
trackler-2.2.1.166 tracks/lua/exercises/change/change_spec.lua
trackler-2.2.1.165 tracks/lua/exercises/change/change_spec.lua
trackler-2.2.1.164 tracks/lua/exercises/change/change_spec.lua
trackler-2.2.1.163 tracks/lua/exercises/change/change_spec.lua
trackler-2.2.1.162 tracks/lua/exercises/change/change_spec.lua
trackler-2.2.1.161 tracks/lua/exercises/change/change_spec.lua
trackler-2.2.1.160 tracks/lua/exercises/change/change_spec.lua