Created
June 2, 2020 16:31
-
-
Save ahenaor/3a7fd084f45efca7ececd7e3fd17c7d8 to your computer and use it in GitHub Desktop.
Código 2 Entrevista Data Science Junior
This file contains 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 busqueda_vector (n, vector): | |
resultado = [] | |
contador = 0 | |
i = 0 | |
j = 0 | |
while i < len(vector): | |
contador = contador + vector[i] | |
if contador < n: | |
resultado.append(vector[i]) | |
elif contador > n: | |
i = j | |
j += 1 | |
resultado = [] | |
contador = 0 | |
else: | |
resultado.append(vector[i]) | |
print(resultado) | |
i = j | |
j += 1 | |
resultado = [] | |
contador = 0 | |
i += 1 | |
busqueda_vector(n, vector) | |
vector = [ 3, 5, 1, 8, 3, 2, 1, 7, 2, 4, 5, 8, 1] | |
n = 10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment