21 December 2017

UVA 11541 Python solution

from sys import stdin
scan = lambda : stdin.readline()

test = int(scan())

for case in range(1,test+1):
    text = scan()
    counter =0    print("Case %d: "%case,end='')
    for i in range(0,len(text)):
        if text[i]>='A' and text[i]<='Z':
            txt = text[i]
        elif text[i]>='0' and text[i]<='9':
            counter = (counter*10) + int(text[i])
        if i == len(text)-1 or (text[i+1]>='A' and text[i+1]<='Z'):
            for k in range(1,counter+1):
                print(txt,end='')
            counter =0    print()

No comments:

Post a Comment

UVA 10679 - I Love Strings!!