Sha256: 0b998459041c140c5486e097db76da73608a4fe697927dd8269f01f96fb8ed30

Contents?: true

Size: 1.07 KB

Versions: 396

Compression:

Stored size: 1.07 KB

Contents

local Triangle = require('pascals-triangle')

describe('pascals-triangle', function()
  it('should generate a triangle with one row', function()
    assert.same({ { 1 } }, Triangle(1).rows)
  end)

  it('should generate a triangle with two rows', function()
    assert.same({ { 1 }, { 1, 1 } }, Triangle(2).rows)
  end)

  it('should generate a triangle with three rows', function()
    assert.same({ { 1 }, { 1, 1 }, { 1, 2, 1 } }, Triangle(3).rows)
  end)

  it('should allow the last row to be accessed directly', function()
    assert.same({ 1, 2, 1 }, Triangle(3).last_row)
  end)

  it('should generate the fourth row correctly', function()
    assert.same({ 1, 3, 3, 1 }, Triangle(4).last_row)
  end)

  it('should generate the fifth row correctly', function()
    assert.same({ 1, 4, 6, 4, 1 }, Triangle(5).last_row)
  end)

  it('should generate the twentieth row correctly', function()
    local twentieth = { 1, 19, 171, 969, 3876, 11628, 27132, 50388, 75582, 92378, 92378, 75582, 50388, 27132, 11628, 3876, 969, 171, 19, 1 }
    assert.same(twentieth, Triangle(20).last_row)
  end)
end)

Version data entries

396 entries across 396 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/lua/exercises/pascals-triangle/pascals-triangle_spec.lua
trackler-2.2.1.179 tracks/lua/exercises/pascals-triangle/pascals-triangle_spec.lua
trackler-2.2.1.178 tracks/lua/exercises/pascals-triangle/pascals-triangle_spec.lua
trackler-2.2.1.177 tracks/lua/exercises/pascals-triangle/pascals-triangle_spec.lua
trackler-2.2.1.176 tracks/lua/exercises/pascals-triangle/pascals-triangle_spec.lua
trackler-2.2.1.175 tracks/lua/exercises/pascals-triangle/pascals-triangle_spec.lua
trackler-2.2.1.174 tracks/lua/exercises/pascals-triangle/pascals-triangle_spec.lua
trackler-2.2.1.173 tracks/lua/exercises/pascals-triangle/pascals-triangle_spec.lua
trackler-2.2.1.172 tracks/lua/exercises/pascals-triangle/pascals-triangle_spec.lua
trackler-2.2.1.171 tracks/lua/exercises/pascals-triangle/pascals-triangle_spec.lua
trackler-2.2.1.170 tracks/lua/exercises/pascals-triangle/pascals-triangle_spec.lua
trackler-2.2.1.169 tracks/lua/exercises/pascals-triangle/pascals-triangle_spec.lua
trackler-2.2.1.167 tracks/lua/exercises/pascals-triangle/pascals-triangle_spec.lua
trackler-2.2.1.166 tracks/lua/exercises/pascals-triangle/pascals-triangle_spec.lua
trackler-2.2.1.165 tracks/lua/exercises/pascals-triangle/pascals-triangle_spec.lua
trackler-2.2.1.164 tracks/lua/exercises/pascals-triangle/pascals-triangle_spec.lua
trackler-2.2.1.163 tracks/lua/exercises/pascals-triangle/pascals-triangle_spec.lua
trackler-2.2.1.162 tracks/lua/exercises/pascals-triangle/pascals-triangle_spec.lua
trackler-2.2.1.161 tracks/lua/exercises/pascals-triangle/pascals-triangle_spec.lua
trackler-2.2.1.160 tracks/lua/exercises/pascals-triangle/pascals-triangle_spec.lua