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.139 tracks/lua/exercises/kindergarten-garden/example.lua
trackler-2.2.1.138 tracks/lua/exercises/kindergarten-garden/example.lua
trackler-2.2.1.137 tracks/lua/exercises/kindergarten-garden/example.lua
trackler-2.2.1.136 tracks/lua/exercises/kindergarten-garden/example.lua
trackler-2.2.1.135 tracks/lua/exercises/kindergarten-garden/example.lua
trackler-2.2.1.134 tracks/lua/exercises/kindergarten-garden/example.lua
trackler-2.2.1.133 tracks/lua/exercises/kindergarten-garden/example.lua
trackler-2.2.1.132 tracks/lua/exercises/kindergarten-garden/example.lua
trackler-2.2.1.131 tracks/lua/exercises/kindergarten-garden/example.lua
trackler-2.2.1.130 tracks/lua/exercises/kindergarten-garden/example.lua
trackler-2.2.1.129 tracks/lua/exercises/kindergarten-garden/example.lua
trackler-2.2.1.128 tracks/lua/exercises/kindergarten-garden/example.lua
trackler-2.2.1.127 tracks/lua/exercises/kindergarten-garden/example.lua
trackler-2.2.1.126 tracks/lua/exercises/kindergarten-garden/example.lua
trackler-2.2.1.125 tracks/lua/exercises/kindergarten-garden/example.lua
trackler-2.2.1.124 tracks/lua/exercises/kindergarten-garden/example.lua
trackler-2.2.1.123 tracks/lua/exercises/kindergarten-garden/example.lua
trackler-2.2.1.122 tracks/lua/exercises/kindergarten-garden/example.lua
trackler-2.2.1.121 tracks/lua/exercises/kindergarten-garden/example.lua
trackler-2.2.1.120 tracks/lua/exercises/kindergarten-garden/example.lua