Skip to main content
edited body
Source Link
Dennis
  • 210.6k
  • 41
  • 370
  • 825

Julia, 62 59 58 bytes

f(s,p,r,_=try)=(try s[[i=findnext(s,c,i+1)for c=p]'],i=r,0end0end;s)=s

I/O is in form of character arrays.

Verification

julia> f(s,p,r,_=try)=(try s[[i=findnext(s,c,i+1)for c=p]'],i=r,0end0end;s)=s
f (generic function with 2 methods)

julia> F(s,p,r)=join(f([s...],[p...],[r...])) # string/char array conversion
F (generic function with 1 method)

julia> F("aacbcbabcccaabcbabcaabbbbca","abaaaccbac","1223334444")
"aacbcbabcccaabcbabcaabbbbca"

julia> F("aacbcbabcccaabcbabcaabbbbcac","abaaaccbac","1223334444")
"1ac2cb2bccc33b3bab4aa4bbbc44"

Julia, 62 59 58 bytes

f(s,p,r,_=try s[[i=findnext(s,c,i+1)for c=p]'],i=r,0end)=s

I/O is in form of character arrays.

Verification

julia> f(s,p,r,_=try s[[i=findnext(s,c,i+1)for c=p]'],i=r,0end)=s
f (generic function with 2 methods)

julia> F(s,p,r)=join(f([s...],[p...],[r...])) # string/char array conversion
F (generic function with 1 method)

julia> F("aacbcbabcccaabcbabcaabbbbca","abaaaccbac","1223334444")
"aacbcbabcccaabcbabcaabbbbca"

julia> F("aacbcbabcccaabcbabcaabbbbcac","abaaaccbac","1223334444")
"1ac2cb2bccc33b3bab4aa4bbbc44"

Julia, 62 59 58 bytes

f(s,p,r)=(try s[[i=findnext(s,c,i+1)for c=p]'],i=r,0end;s)

I/O is in form of character arrays.

Verification

julia> f(s,p,r)=(try s[[i=findnext(s,c,i+1)for c=p]'],i=r,0end;s)
f (generic function with 2 methods)

julia> F(s,p,r)=join(f([s...],[p...],[r...])) # string/char array conversion
F (generic function with 1 method)

julia> F("aacbcbabcccaabcbabcaabbbbca","abaaaccbac","1223334444")
"aacbcbabcccaabcbabcaabbbbca"

julia> F("aacbcbabcccaabcbabcaabbbbcac","abaaaccbac","1223334444")
"1ac2cb2bccc33b3bab4aa4bbbc44"
added 9 characters in body
Source Link
Dennis
  • 210.6k
  • 41
  • 370
  • 825

Julia, 62 5959 58 bytes

f(s,p,r)=(try,_=try i=0;s[[i=findnexts[[i=findnext(s,c,i+1)for c=p]']=r end;sc=p]'],i=r,0end)=s

I/O is in form of character arrays.

Verification

julia> f(s,p,r)=(try,_=try i=0;s[[i=findnexts[[i=findnext(s,c,i+1)for c=p]']=r end;sc=p]'],i=r,0end)=s
f (generic function with 12 methodmethods)

julia> F(s,p,r)=join(f([s...],[p...],[r...])) # string/char array conversion
F (generic function with 1 method)

julia> F("aacbcbabcccaabcbabcaabbbbca","abaaaccbac","1223334444")
"aacbcbabcccaabcbabcaabbbbca"

julia> F("aacbcbabcccaabcbabcaabbbbcac","abaaaccbac","1223334444")
"1ac2cb2bccc33b3bab4aa4bbbc44"

Julia, 62 59 bytes

f(s,p,r)=(try i=0;s[[i=findnext(s,c,i+1)for c=p]']=r end;s)

I/O is in form of character arrays.

Verification

julia> f(s,p,r)=(try i=0;s[[i=findnext(s,c,i+1)for c=p]']=r end;s)
f (generic function with 1 method)

julia> F(s,p,r)=join(f([s...],[p...],[r...])) # string/char array conversion
F (generic function with 1 method)

julia> F("aacbcbabcccaabcbabcaabbbbca","abaaaccbac","1223334444")
"aacbcbabcccaabcbabcaabbbbca"

julia> F("aacbcbabcccaabcbabcaabbbbcac","abaaaccbac","1223334444")
"1ac2cb2bccc33b3bab4aa4bbbc44"

Julia, 62 59 58 bytes

f(s,p,r,_=try s[[i=findnext(s,c,i+1)for c=p]'],i=r,0end)=s

I/O is in form of character arrays.

Verification

julia> f(s,p,r,_=try s[[i=findnext(s,c,i+1)for c=p]'],i=r,0end)=s
f (generic function with 2 methods)

julia> F(s,p,r)=join(f([s...],[p...],[r...])) # string/char array conversion
F (generic function with 1 method)

julia> F("aacbcbabcccaabcbabcaabbbbca","abaaaccbac","1223334444")
"aacbcbabcccaabcbabcaabbbbca"

julia> F("aacbcbabcccaabcbabcaabbbbcac","abaaaccbac","1223334444")
"1ac2cb2bccc33b3bab4aa4bbbc44"
added 7 characters in body
Source Link
Dennis
  • 210.6k
  • 41
  • 370
  • 825

Julia, 6262 59 bytes

f(s,p,r,i=0,j=[i=findnext)=(try i=0;s[[i=findnext(s,c,i+1)for c=p])=0∈j?s:(s[j]=r;sc=p]']=r end;s)

I/O is in form of character arrays.

Verification

julia> f(s,p,r,i=0,j=[i=findnext)=(try i=0;s[[i=findnext(s,c,i+1)for c=p])=0∈j?s:(s[j]=r;sc=p]']=r end;s)
f (generic function with 31 methodsmethod)

julia> F(s,p,r)=join(f([s...],[p...],[r...])) # string/char array conversion
F (generic function with 1 method)

julia> F("aacbcbabcccaabcbabcaabbbbca","abaaaccbac","1223334444")
"aacbcbabcccaabcbabcaabbbbca"

julia> F("aacbcbabcccaabcbabcaabbbbcac","abaaaccbac","1223334444")
"1ac2cb2bccc33b3bab4aa4bbbc44"

Julia, 62 bytes

f(s,p,r,i=0,j=[i=findnext(s,c,i+1)for c=p])=0∈j?s:(s[j]=r;s)

I/O is in form of character arrays.

Verification

julia> f(s,p,r,i=0,j=[i=findnext(s,c,i+1)for c=p])=0∈j?s:(s[j]=r;s)
f (generic function with 3 methods)

julia> F(s,p,r)=join(f([s...],[p...],[r...])) # string/char array conversion
F (generic function with 1 method)

julia> F("aacbcbabcccaabcbabcaabbbbca","abaaaccbac","1223334444")
"aacbcbabcccaabcbabcaabbbbca"

julia> F("aacbcbabcccaabcbabcaabbbbcac","abaaaccbac","1223334444")
"1ac2cb2bccc33b3bab4aa4bbbc44"

Julia, 62 59 bytes

f(s,p,r)=(try i=0;s[[i=findnext(s,c,i+1)for c=p]']=r end;s)

I/O is in form of character arrays.

Verification

julia> f(s,p,r)=(try i=0;s[[i=findnext(s,c,i+1)for c=p]']=r end;s)
f (generic function with 1 method)

julia> F(s,p,r)=join(f([s...],[p...],[r...])) # string/char array conversion
F (generic function with 1 method)

julia> F("aacbcbabcccaabcbabcaabbbbca","abaaaccbac","1223334444")
"aacbcbabcccaabcbabcaabbbbca"

julia> F("aacbcbabcccaabcbabcaabbbbcac","abaaaccbac","1223334444")
"1ac2cb2bccc33b3bab4aa4bbbc44"
Source Link
Dennis
  • 210.6k
  • 41
  • 370
  • 825
Loading