Skip to content

Instantly share code, notes, and snippets.

@denisdemaisbr
Last active May 20, 2017 17:55
Show Gist options
  • Save denisdemaisbr/92a170a6cf120c85490d1c81467d25b2 to your computer and use it in GitHub Desktop.
Save denisdemaisbr/92a170a6cf120c85490d1c81467d25b2 to your computer and use it in GitHub Desktop.
---
--- license: public domain
--- author: denis dos santos silva
--- date : 20/05/17
--- lua 5.1+
---
function processa(data)
local _c3 = {};
local _c;
for i=1, #data do
_c = data[i];
if (_c == 'A') then _c3[#_c3+1] = 'T'; -- a->t
elseif (_c == 'T') then _c3[#_c3+1] = 'A'; -- t->a
elseif (_c == 'C') then _c3[#_c3+1] = 'G'; -- c->g
elseif (_c == 'G') then _c3[#_c3+1] = 'C'; -- g->c
else
_c3[#_c3+1] = '?';
end
end
return _c3;
end
function implode(str)
local r = {};
str:upper():gsub('.' , function (c) table.insert(r, c); return end);
return r;
end
--
-- main
--
local c1, c2, c3;
c1 = io.read();
c2 = implode(c1);
print('\n\n');
print('input', table.concat(c2, ","));
c3 = processa(c2);
print('output', table.concat(c3, ","));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment