Skip to content

Latest commit

 

History

History
45 lines (43 loc) · 1.33 KB

File metadata and controls

45 lines (43 loc) · 1.33 KB
def solution(survey, choices):
    pair = [0,3,2,1,0,1,2,3]
    count = len(choices)
    answer=[0,0,0,0]
    def makeMBTI(answer, s,score):
        if s == "R":
            #print("R")
            answer[0]+=score
        elif s =="T":
            answer[0]-=score
        elif s == "C":
            answer[1]+=score
        elif s == "F":
            answer[1]-=score
        elif s == "J":
            answer[2]+=score
        elif s == "M":
            answer[2]-=score
        elif s == "A":
            answer[3]+=score
        elif s == "N":
            answer[3]-=score
        return answer
    for c in range(count):
        s,e= survey[c][0], survey[c][1]
       # print(s,e,c,pair[choices[c] ])
        if choices[c] <4:
            answer = makeMBTI(answer, s,pair[choices[c] ])
           # print(s,pair[choices[c] ])
        elif choices[c] >4:
            answer = makeMBTI(answer, e,pair[choices[c] ])
          #  print(e,pair[choices[c] ])
       # print(answer)
    real_answer=["R","C","J","A"]
    #print(answer)
    minus_val = ["T","F","M","N"]
    for a in range(4):
        if answer[a]<0:
                real_answer[a]=minus_val[a]
  
    return "".join(real_answer)