1
0
mirror of https://github.com/balkian/gists.git synced 2024-11-23 18:02:29 +00:00
This commit is contained in:
J. Fernando Sánchez 2014-02-24 03:40:29 -08:00
parent 5bb55306bb
commit edf3519032

View File

@ -10,11 +10,11 @@
{
"cell_type": "code",
"collapsed": false,
"input": "a=set([1,2,3,4])\nb=set([4,5,6,7])\nc=set([7,8,9])",
"input": "a=set([3,4])\nb=set([3,7])",
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 5
"prompt_number": 112
},
{
"cell_type": "code",
@ -28,37 +28,26 @@
{
"cell_type": "code",
"collapsed": false,
"input": "def shuffle(*args):\n combinations = [[i] for i in args[0]]\n for arg in args[1:]:\n tempcomb = []\n for i in arg:\n print i\n tempcomb += [c+[i] for c in combinations if i not in c ]\n combinations = tempcomb\n return combinations\nshuffle(a,b,c)",
"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)",
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": "4\n5\n6\n7\n8\n9\n7\n"
"text": "[[4, 3], [3, 7], [4, 7]]\n3\n"
}
],
"prompt_number": 50
"prompt_number": 115
},
{
"cell_type": "code",
"collapsed": false,
"input": "x= [2,4,3]\nx + 6",
"input": "",
"language": "python",
"metadata": {},
"outputs": [
{
"ename": "TypeError",
"evalue": "can only concatenate list (not \"int\") to list",
"output_type": "pyerr",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)",
"\u001b[1;32m<ipython-input-27-8c5a19772838>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[0mx\u001b[0m\u001b[1;33m=\u001b[0m \u001b[1;33m[\u001b[0m\u001b[1;36m2\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;36m4\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;36m3\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 2\u001b[1;33m \u001b[0mx\u001b[0m \u001b[1;33m+\u001b[0m \u001b[1;36m6\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[1;31mTypeError\u001b[0m: can only concatenate list (not \"int\") to list"
]
}
],
"prompt_number": 27
"outputs": [],
"prompt_number": 56
},
{
"cell_type": "code",