mirror of
https://github.com/balkian/gists.git
synced 2024-11-21 17:22:29 +00:00
This commit is contained in:
parent
ab7fa8f286
commit
5691cd367b
@ -10,26 +10,26 @@
|
|||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"collapsed": false,
|
"collapsed": false,
|
||||||
"input": "a=set([3,4])\nb=set([3])\nc=set([4])\n",
|
"input": "a=set([3,4])\nb=set([3,7])\nc=set([4])\n",
|
||||||
"language": "python",
|
"language": "python",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"prompt_number": 1
|
"prompt_number": 6
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"collapsed": false,
|
"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 if tempcomb:\n combinations = tempcomb\n return combinations\nres = array_combinations(a,b,c)\nprint res\nprint len(res)",
|
"input": "def array_combinations(*args):\n combinations = [set([i]) for i in set(args[0])]\n for arg in args[1:]:\n tempcomb = []\n for i in set(arg):\n for c in combinations:\n c.update([i])\n tempcomb.append(c)\n if tempcomb:\n combinations = tempcomb\n return combinations\nres = array_combinations(a,b,c)\nprint res\nprint len(res)",
|
||||||
"language": "python",
|
"language": "python",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
{
|
{
|
||||||
"output_type": "stream",
|
"output_type": "stream",
|
||||||
"stream": "stdout",
|
"stream": "stdout",
|
||||||
"text": "[[4, 3]]\n1\n"
|
"text": "[set([3, 4, 7]), set([3, 4, 7]), set([3, 4, 7]), set([3, 4, 7])]\n4\n"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"prompt_number": 5
|
"prompt_number": 25
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"metadata": {}
|
"metadata": {}
|
||||||
|
Loading…
Reference in New Issue
Block a user