24 lines
627 B
Mojo
24 lines
627 B
Mojo
# Generated by Programming+ from pseudo. Not reviewed for Mojo best practices.
|
|
|
|
# Matched is reset in the wrong place.
|
|
def match_(p: String, t: String) -> List[Int]:
|
|
var n: Int
|
|
var m: Int
|
|
var matched: Bool
|
|
var answer = List[Int]()
|
|
n = t.count_codepoints()
|
|
m = p.count_codepoints()
|
|
matched = True
|
|
for i in range(n - m + 1):
|
|
for j in range(m):
|
|
if String(t[codepoint=i + j]) != String(p[codepoint=j]):
|
|
matched = False
|
|
break
|
|
if matched:
|
|
answer.append(i)
|
|
return answer.copy()
|
|
|
|
|
|
def main():
|
|
print(match_("GC", "GATGCA"))
|