Skip to content

Instantly share code, notes, and snippets.

@sbrmnn
Created September 1, 2021 01:23
Show Gist options
  • Save sbrmnn/322f33eebb5bcddc344e8b23a468f2b3 to your computer and use it in GitHub Desktop.
Save sbrmnn/322f33eebb5bcddc344e8b23a468f2b3 to your computer and use it in GitHub Desktop.
dna
def maybe_match(s1, s2)
s1pointer = 0
s2pointer = 0
until s1pointer == s1.size
if s1[s1pointer] == s2[s2pointer] || s1[s1pointer] == 'N'
s1pointer+=1
s2pointer+=1
else
s2pointer = 0
s1pointer +=1 if s1[s1pointer] != s2[s2pointer]
end
return true if s2pointer == s2.size
end
false
end
puts maybe_match("ACNTAGNC","ACGT")
puts maybe_match("ACNTAGNC", "TAG")
puts maybe_match("ACNTAGNC", "GGGG")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment