← Back to List

11078번: Banking ↗

Solutions

Python 3
767 B | 767 chars
import sys
from math import sqrt, pi, sin, factorial, ceil, floor
from datetime import datetime, timedelta
sys.setrecursionlimit(10**7)

BLANK = " "

#inp = input
inp = lambda : sys.stdin.readline().rstrip()
mii = lambda x = BLANK : [*map(int,inp().split(x))]
mfi = lambda x = BLANK : [*map(float,inp().split(x))]
ii = lambda : int(inp())
fi = lambda : float(inp())
p = print


def solve():
  a = input()
  b = input()
  
  idx = 0
  ans = ""
  for i in b:
    c = 0
    if 'a' <= i <= 'z':
      c = ord(i) - 96
      
      ans += a[idx:idx+c]
    else:
      c = ord(i) - 64
    
    idx += c
  
  if idx != len(a):
    p("non sequitur")
  else:
    p(sum([*map(int, list(ans))]))

if __name__ == "__main__":
  tc = 1

  for t in range(1, tc+1):
    ret = solve()