백준 [ALGORITHM] - Javascript

2023. 2. 2. 16:37코딩/백준 [ALGORITHM]

반응형
try:
    x,y = map(list,input().split(" "))
    result = ""

    for i in range(len(x)):
        x[i] = ord(x[i])
    for j in range(len(y)):
        y[j] = ord(y[j])

    for z in range(len(x)):
        for c in range(65,123):
            if x[z] == c:
                result = "NaN"
            
    for z in range(len(y)):
        for c in range(65,123):
            if y[z] == c:
                result = "NaN"

    for i in range(len(x)):
        x[i] = chr(x[i])
    for j in range(len(y)):
        y[j] = chr(y[j])


    if result == "NaN":
        print("NaN")
    else:
        a = ''.join(map(str,x))
        b = ''.join(map(str,y))
        print(int(a)-int(b))
except:
    print("NaN")
반응형