Skip to content

Instantly share code, notes, and snippets.

@yuhangwang
Last active February 3, 2022 03:43
Show Gist options
  • Save yuhangwang/eb9f2b0f567f1f14b311b303306172d0 to your computer and use it in GitHub Desktop.
Save yuhangwang/eb9f2b0f567f1f14b311b303306172d0 to your computer and use it in GitHub Desktop.
# see: https://www.deepmind.com/blog/article/Competitive-programming-with-AlphaCode
# Why AlphaCode generated an unused variable `c` to store a string that has no use at all?
t = int(input())
for i in range(t):
s = input()
t = input()
a = []
b = []
for j in s:
a.append(j)
for j in t:
b.append(j)
a.reverse()
b.reverse()
c = []
while len(b) != 0 and len(a) != 0:
if a[0] == b[0]:
c.append(b.pop(0))
a.pop(0)
elif a[0] != b[0] and len(a) != 1:
a.pop(0)
a.pop(0)
elif a[0] != b[0] and len(a) == 1:
a.pop(0)
if len(b) == 0:
print("YES")
else:
print("NO")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment