Sha256: edf336cdba93fd050236a50c2eb8740a9597e60e0950540466d9b4ebae1ac52e

Contents?: true

Size: 273 Bytes

Versions: 396

Compression:

Stored size: 273 Bytes

Contents

return function(n)
  local rows = { { 1 } }

  for i = 1, n - 1 do
    local row = {}
    for j = 1, i + 1 do
      row[j] = (rows[i][j - 1] or 0) + (rows[i][j] or 0)
    end
    table.insert(rows, row)
  end

  return {
    rows = rows,
    last_row = rows[#rows]
  }
end

Version data entries

396 entries across 396 versions & 1 rubygems

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