1
0
mirror of https://github.com/balkian/gists.git synced 2024-12-23 22:58:12 +00:00
This commit is contained in:
J. Fernando Sánchez 2014-02-25 07:00:17 -08:00
parent 9d35c53858
commit ab7fa8f286

View File

@ -10,26 +10,26 @@
{
"cell_type": "code",
"collapsed": false,
"input": "a=set([3,4])\nb=set([3,7])",
"input": "a=set([3,4])\nb=set([3])\nc=set([4])\n",
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 112
"prompt_number": 1
},
{
"cell_type": "code",
"collapsed": false,
"input": "def array_combinations(*args):\n combinations = [[i] for i in set(args[0])]\n for arg in args[1:]:\n tempcomb = []\n for i in set(arg):\n tempcomb += [c+[i] for c in combinations if i not in c ]\n combinations = tempcomb\n return combinations\nres = array_combinations(a,b)\nprint res\nprint len(res)",
"input": "def array_combinations(*args):\n combinations = [[i] for i in set(args[0])]\n for arg in args[1:]:\n tempcomb = []\n for i in set(arg):\n tempcomb += [c+[i] for c in combinations if i not in c ]\n if tempcomb:\n combinations = tempcomb\n return combinations\nres = array_combinations(a,b,c)\nprint res\nprint len(res)",
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": "[[4, 3], [3, 7], [4, 7]]\n3\n"
"text": "[[4, 3]]\n1\n"
}
],
"prompt_number": 116
"prompt_number": 5
}
],
"metadata": {}