Skip to main content
This works only if "The second string will always be longer than enough."
Source Link

Python 3.5, 7267

def f(a,b):b=[*b];return"".join(y==b[0]and b.pop(0)or"#"for y in a if b)

Ungolfed:

def f(a, b):
    b = [*b] #Convert string to list; yeah Python 3.5
    c = []
    for y in a:
       if b and y==b[0]:
          c.append(b.pop(0))
       else:
          c.append("#")
    return "".join(c)

Try it herehere

Python 3.5, 72

def f(a,b):b=[*b];return"".join(y==b[0]and b.pop(0)or"#"for y in a if b)

Ungolfed:

def f(a, b):
    b = [*b] #Convert string to list; yeah Python 3.5
    c = []
    for y in a:
       if b and y==b[0]:
          c.append(b.pop(0))
       else:
          c.append("#")
    return "".join(c)

Try it here

Python 3.5, 67

def f(a,b):b=[*b];return"".join(y==b[0]and b.pop(0)or"#"for y in a)

Ungolfed:

def f(a, b):
    b = [*b] #Convert string to list; yeah Python 3.5
    c = []
    for y in a:
       if y==b[0]:
          c.append(b.pop(0))
       else:
          c.append("#")
    return "".join(c)

Try it here

Found out a function is not cheating.
Source Link

Python 3.5, 8272

i=input
a,b=[*idef f()]a,[*i(b)]
print:b=[*b];return"".join(*[y==b[0]andy==b[0]and b.pop(0)or"#"for y in a if b]b)

Ungolfed:

def f(a,sep="" b):
    b = [*b] #Convert string to list; yeah Python 3.5
    c = []
    for y in a:
       if b and y==b[0]:
          c.append(b.pop(0))
       else:
          c.append("#")
    return "".join(c)

Try it here

I know there ist a shorter solution from Morgan Thrapp but IMHO defining a function is kinda cheating.here

Python 3.5, 82

i=input
a,b=[*i()],[*i()]
print(*[y==b[0]and b.pop(0)or"#"for y in a if b],sep="")

Try it here

I know there ist a shorter solution from Morgan Thrapp but IMHO defining a function is kinda cheating.

Python 3.5, 72

def f(a,b):b=[*b];return"".join(y==b[0]and b.pop(0)or"#"for y in a if b)

Ungolfed:

def f(a, b):
    b = [*b] #Convert string to list; yeah Python 3.5
    c = []
    for y in a:
       if b and y==b[0]:
          c.append(b.pop(0))
       else:
          c.append("#")
    return "".join(c)

Try it here

explanation for longer solution
Source Link

Python 3.5, 82

i=input
a,b=[*i()],[*i()]
print(*[y==b[0]and b.pop(0)or"#"for y in a if b],sep="")

Try it here

I know there ist a shorter solution from Morgan Thrapp but IMHO defining a function is kinda cheating.

Python 3.5, 82

i=input
a,b=[*i()],[*i()]
print(*[y==b[0]and b.pop(0)or"#"for y in a if b],sep="")

Try it here

Python 3.5, 82

i=input
a,b=[*i()],[*i()]
print(*[y==b[0]and b.pop(0)or"#"for y in a if b],sep="")

Try it here

I know there ist a shorter solution from Morgan Thrapp but IMHO defining a function is kinda cheating.

Source Link
Loading