Created
February 10, 2017 01:11
-
-
Save purplexa/39d44387676df359815a1c55b0dd609f to your computer and use it in GitHub Desktop.
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
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