Skip to content

Instantly share code, notes, and snippets.

@vesche
Created April 7, 2019 02:01
Show Gist options
  • Save vesche/e074dedb3a79ea36620d4486d8f38edb to your computer and use it in GitHub Desktop.
Save vesche/e074dedb3a79ea36620d4486d8f38edb to your computer and use it in GitHub Desktop.
# 1
for c in range(int(input())):
n = int(input())
a = n
for i, d in enumerate(reversed(str(n))):
if d == '4':
a -= 10 ** i
b = n - a
print('Case #{0}: {1} {2}'.format(c+1, a, b))
# 2
for n in range(int(input())):
_, steps = input(), input()
out = ''
c, x, y, = 0, 0, 0
for i, s in enumerate(steps):
if s == 'E': y += 1
else: x += 1
if x == y:
out += steps[c:i+1][::-1]
c = i + 1
print('Case #{0}: {1}'.format(n+1, out))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment