Skip to content

Instantly share code, notes, and snippets.

@RafaelBroseghini
Created November 14, 2018 04:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RafaelBroseghini/12a979b4ccaf31a8d00059e5b0b4930f to your computer and use it in GitHub Desktop.
Save RafaelBroseghini/12a979b4ccaf31a8d00059e5b0b4930f to your computer and use it in GitHub Desktop.
Guess and Check Pattern
"""
This pattern guesses and checks if there are any even numbers in a given array
and returns True or False.
"""
def guess_and_check(array: list) -> bool:
if len(array) == 0:
return False
found = False
i = 0
while not found and i < len(array):
if array[i] % 2 == 0:
found = True
i += 1
return found
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment