Sha256: 01cfeeda332217115104da8a5f657f3ed5708aaea03139a4d01f12bef09c043d

Contents?: true

Size: 460 Bytes

Versions: 396

Compression:

Stored size: 460 Bytes

Contents

local DNA = {}

function DNA:new(str)
  self.__index = self
  local nc = { A = 0, T = 0, C = 0, G = 0 }
  local n = { 'A','T','C','G' }
  for i = 1, str:len() do
    local c = str:sub(i,i)
    nc[c]= nc[c] + 1
  end
  return setmetatable({ nucleotideCounts = nc, NUCLEOTIDES = n }, self)
end

function DNA:count(symbol)
  if self.nucleotideCounts[symbol] then
    return self.nucleotideCounts[symbol]
  end
  return error('Invalid Nucleotide')
end

return DNA

Version data entries

396 entries across 396 versions & 1 rubygems

Version Path
trackler-2.2.1.119 tracks/lua/exercises/nucleotide-count/example.lua
trackler-2.2.1.118 tracks/lua/exercises/nucleotide-count/example.lua
trackler-2.2.1.117 tracks/lua/exercises/nucleotide-count/example.lua
trackler-2.2.1.116 tracks/lua/exercises/nucleotide-count/example.lua
trackler-2.2.1.115 tracks/lua/exercises/nucleotide-count/example.lua
trackler-2.2.1.114 tracks/lua/exercises/nucleotide-count/example.lua
trackler-2.2.1.113 tracks/lua/exercises/nucleotide-count/example.lua
trackler-2.2.1.111 tracks/lua/exercises/nucleotide-count/example.lua
trackler-2.2.1.110 tracks/lua/exercises/nucleotide-count/example.lua
trackler-2.2.1.109 tracks/lua/exercises/nucleotide-count/example.lua
trackler-2.2.1.108 tracks/lua/exercises/nucleotide-count/example.lua
trackler-2.2.1.107 tracks/lua/exercises/nucleotide-count/example.lua
trackler-2.2.1.106 tracks/lua/exercises/nucleotide-count/example.lua
trackler-2.2.1.105 tracks/lua/exercises/nucleotide-count/example.lua
trackler-2.2.1.104 tracks/lua/exercises/nucleotide-count/example.lua
trackler-2.2.1.103 tracks/lua/exercises/nucleotide-count/example.lua
trackler-2.2.1.102 tracks/lua/exercises/nucleotide-count/example.lua
trackler-2.2.1.101 tracks/lua/exercises/nucleotide-count/example.lua
trackler-2.2.1.100 tracks/lua/exercises/nucleotide-count/example.lua
trackler-2.2.1.99 tracks/lua/exercises/nucleotide-count/example.lua