Skip to content

Instantly share code, notes, and snippets.

@purplexa
Created February 10, 2017 01:11
Show Gist options
  • Save purplexa/39d44387676df359815a1c55b0dd609f to your computer and use it in GitHub Desktop.
Save purplexa/39d44387676df359815a1c55b0dd609f to your computer and use it in GitHub Desktop.
foo = [1, 3, 5, 2, 3]
bar = [1, 3, 5, 2, 4, 8]
def generate_checks(num_list):
checks = []
if len(num_list) == 0:
return checks
for i in range(len(num_list[1:])):
checks.append(lambda: num_list[0] == num_list[i+1])
return checks + generate_checks(num_list[1:])
def check_two(checks):
state = False
def check_two_generator():
for check in checks:
yield check()
for x in check_two_generator():
if state and x:
return True
state = state or x
return False
print(check_two(generate_checks(foo)))
print(check_two(generate_checks(bar)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment