UVa 11203 - Can you decide it for ME? Solution

import re
def Main():
    patt=re.compile(r'^(\?+)M(\?+)E(\?+)$')
    n=int(input())
    while n>0:
        n-=1
        s=input()
        res=patt.match(s)
        if (res is not None) and (len(res.group(1))+len(res.group(2)))==len(res.group(3)):
            print("theorem")
        else:
            print("no-theorem")
if __name__=="__main__":
    Main()

Comments