Created
September 19, 2019 01:27
-
-
Save rodpoblete/bea0a514426e1f3aa065e1301d4eb4ca to your computer and use it in GitHub Desktop.
Problema IQTest de codewars. Se entrega una serie de números en formato de cadena de texto, y de debe encontrar cuál difiere de los demás.
(números pares e impares)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def iq_test(numbers): | |
l = numbers.split(' ') | |
l2 = [int(n) for n in l] | |
odd_list = [l2.index(n) for n in l2 if n % 2 != 0] | |
even_list = [l2.index(x) for x in l2 if x % 2 == 0] | |
if len(odd_list) == 1: | |
odd_index = odd_list[0] + 1 | |
return odd_index | |
else: | |
even_index = even_list[0] + 1 | |
return even_index |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment