Created
September 1, 2021 01:23
-
-
Save sbrmnn/322f33eebb5bcddc344e8b23a468f2b3 to your computer and use it in GitHub Desktop.
dna
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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