diff --git a/nucleotide-count/example.lua b/nucleotide-count/example.lua index d7fbaf1f..030aa9d8 100644 --- a/nucleotide-count/example.lua +++ b/nucleotide-count/example.lua @@ -3,7 +3,7 @@ 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','U'} + local n = { 'A','T','C','G'} for i =1,str:len() do local c = str:sub(i,i) nc[c]= nc[c] + 1 @@ -12,15 +12,10 @@ function DNA:new(str) end function DNA:count(symbol) - if ( self.nucleotideCounts[symbol] ) then + if ( self.nucleotideCounts[symbol] ) then return self.nucleotideCounts[symbol] - end - for _,v in pairs(self.NUCLEOTIDES) do - if v == symbol then - return 0 - end end return error("Invalid Nucleotide") end -return DNA \ No newline at end of file +return DNA diff --git a/nucleotide-count/nucleotide-count_test.lua b/nucleotide-count/nucleotide-count_test.lua index acd79a3d..f999f549 100644 --- a/nucleotide-count/nucleotide-count_test.lua +++ b/nucleotide-count/nucleotide-count_test.lua @@ -1,6 +1,6 @@ local DNA = require('nucleotide-count') -describe('DNA', function() +describe('DNA', function() it('has no nucleotides', function() local expected = { A = 0, T = 0, C = 0, G = 0 } @@ -44,13 +44,6 @@ describe('DNA', function() assert.are.same(expected,result) end) - it('has no uracil', function() - local dna = DNA:new('GGTTGG') - expected = 0 - result = dna:count('U') - assert.are.same(expected,result) - end) - it('validates nucleotides', function() local dna = DNA:new('GGTTGG') assert.has.errors(function() dna:count('X') end)