Algorithm/codewars

IQ Test 답안

Bonita SY 2021. 4. 1. 20:30
728x90
반응형

문제)

www.codewars.com/kata/552c028c030765286c00007d/train/python

 

Codewars: Achieve mastery through challenge

Codewars is where developers achieve code mastery through challenge. Train on kata in the dojo and reach your highest potential.

www.codewars.com

 

내가 푼 답)

def iq_test(numbers):
    remain = [ int(num)%2 for num in numbers.split(' ')]
    for i in range(len(remain) - 2):
        if (remain[i] != remain[i+1]):
            if (remain[i] == remain[i+2]):
                return i+2
            elif (remain[i+1] == remain[i+2]):
                return i+1 
    return len(remain)

 

테스트 결과)

마음에 드는 남이 푼 답)

728x90
반응형