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
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<img src=\"criterion.jpg\" width=400>"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[(0, 4, 2)]"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"def criteria1(x, y, z):\n",
" return x == 6 or y == 8 or z == 2\n",
"\n",
"def criteria2(x, y, z):\n",
" number = [6, 1, 4]\n",
" return ((x in number and x != number[0]) or\n",
" (y in number and y != number[1]) or\n",
" (z in number and z != number[2]))\n",
"\n",
"def criteria3(x, y, z):\n",
" number = [2, 0, 6]\n",
" return (((x in number) + (y in number) + (z in number)) == 2\n",
" and x != number[0]\n",
" and y != number[1]\n",
" and z != number[2])\n",
" \n",
"def criteria4(x, y, z):\n",
" number = [7, 3, 8]\n",
" return x not in number and y not in number and z not in number\n",
" \n",
"def criteria5(x, y, z):\n",
" number = [7, 8, 0]\n",
" return ((x in number and x != number[0]) or\n",
" (y in number and y != number[1]) or\n",
" (z in number and z != number[2]))\n",
" \n",
"[(x, y, z)\n",
" for x in range(0, 9)\n",
" for y in range(0, 9)\n",
" for z in range(0, 9)\n",
" if all(f(x, y, z) for f in [criteria1, criteria2, criteria3, criteria4, criteria5])]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.6"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
# 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