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.

Revisions

  1. yuhangwang revised this gist Feb 3, 2022. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions alphacode-example-1.py
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,5 @@
    # 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()
  2. yuhangwang created this gist Feb 3, 2022.
    27 changes: 27 additions & 0 deletions alphacode-example-1.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    # see: https://www.deepmind.com/blog/article/Competitive-programming-with-AlphaCode
    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")