1
0
mirror of https://github.com/balkian/gists.git synced 2024-11-22 01:32:29 +00:00
This commit is contained in:
J. Fernando Sánchez 2014-02-24 03:39:51 -08:00
commit 5bb55306bb

75
array_combination.ipynb Normal file
View File

@ -0,0 +1,75 @@
{
"metadata": {
"name": "Untitled0"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "code",
"collapsed": false,
"input": "a=set([1,2,3,4])\nb=set([4,5,6,7])\nc=set([7,8,9])",
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 5
},
{
"cell_type": "code",
"collapsed": false,
"input": "def get_nonrepeated(seta, setb):\n for i in seta:\n if i not in setb:\n yield i",
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 9
},
{
"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)",
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": "4\n5\n6\n7\n8\n9\n7\n"
}
],
"prompt_number": 50
},
{
"cell_type": "code",
"collapsed": false,
"input": "x= [2,4,3]\nx + 6",
"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
},
{
"cell_type": "code",
"collapsed": false,
"input": "",
"language": "python",
"metadata": {},
"outputs": []
}
],
"metadata": {}
}
]
}