Skip to content

Instantly share code, notes, and snippets.

@ebraminio
Last active September 12, 2019 05:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ebraminio/212feffe590791da896f66fdb87ce48f to your computer and use it in GitHub Desktop.
Save ebraminio/212feffe590791da896f66fdb87ce48f to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# coding: utf-8
# <img src="criterion.jpg" width=400>
# In[1]:
def criteria1(x, y, z):
return x == 6 or y == 8 or z == 2
def criteria2(x, y, z):
number = [6, 1, 4]
return ((x in number and x != number[0]) or
(y in number and y != number[1]) or
(z in number and z != number[2]))
def criteria3(x, y, z):
number = [2, 0, 6]
return (((x in number) + (y in number) + (z in number)) == 2
and x != number[0]
and y != number[1]
and z != number[2])
def criteria4(x, y, z):
number = [7, 3, 8]
return x not in number and y not in number and z not in number
def criteria5(x, y, z):
number = [7, 8, 0]
return ((x in number and x != number[0]) or
(y in number and y != number[1]) or
(z in number and z != number[2]))
[(x, y, z)
for x in range(0, 9)
for y in range(0, 9)
for z in range(0, 9)
if all(f(x, y, z) for f in [criteria1, criteria2, criteria3, criteria4, criteria5])]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment