throw brick to attract jade
My solution to Jamesxu's problem.
string[ ] p = {"aaabbb", "aaab", "ab}
int [ ] pos = {0,0,0}
loop through target string
loop through number of patterns (n)
s += call match(pos, n, target char, pattern)
if s is 0 then break
end loop
return s
match function
if pos is -1 then return 0
else if target char equals to pattern char at position pos
then increase pos by 1 (don't forget mod here)
return n
else set pos to -1 and return 0