Solución

@baalbornozl_05acdf3a·hace 1dTypeScript
solution.tsTypeScript
def count_attempts(guesses: list, target: int) -> int:
    # Recorre los intentos con while y detente con break cuando encuentres el objetivo
    attempts = 0
    while True:
        try:
            if guesses[attempts] == target:
                return attempts + 1
                break
            else:
                attempts += 1
        except IndexError:
            return -1
0respuestas
Respuestas

Aún no hay respuestas

¡Sé el primero en responder!

Escribir un comentario

Recuerda ser amable. Estás comentando la solución de otra persona. Comparte tu perspectiva de forma constructiva y respetuosa.

Debes iniciar sesión para publicar un comentario.