Sha256: d1a4a8c8a4f2fbf0b03dd8b5dafc10c2e22552b0bdb55823bb24b11718f06570

Contents?: true

Size: 843 Bytes

Versions: 396

Compression:

Stored size: 843 Bytes

Contents

local student_offsets = {
  alice = 0,
  bob = 1,
  charlie = 2,
  david = 3,
  eve = 4,
  fred = 5,
  ginny = 6,
  harriet = 7,
  ileana = 8,
  joseph = 9,
  kincaid = 10,
  larry = 11
}

local plant_abbreviations = { g = 'grass', c = 'clover', r = 'radishes', v = 'violets' }

local function plant_string_for_student(garden, student)
  if not student_offsets[student] then return '' end
  local _, _, row1, row2 = garden:find('(%w+)\n(%w+)')
  local i = 2 * (student_offsets[student]) + 1
  return row1:sub(i, i + 1) .. row2:sub(i, i + 1)
end

return function(s)
  s = s:lower()

  return setmetatable({}, {
    __index = function(_, student)
      local result = {}
      plant_string_for_student(s, student:lower()):gsub('.', function(c)
        table.insert(result, plant_abbreviations[c])
      end)
      return result
    end
  })
end

Version data entries

396 entries across 396 versions & 1 rubygems

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