Suppose I have a list of integers:  myList = [1,2,3,4]   How would one return every possible combination of these two subsets with Python.  For example, set [1,2,3,4] would produce [1,2], [3,4] and [1,3], [2,4] and [1,4],[2,3]
2272
I have a list with 15 numbers in, and I need to write some code that produces all 32,768 combinations of those numbers.   I've found  (by Googling) that apparently does what I'm looking for, but I found the code fairly opaque and am wary of using it. Plus I have a feeling there must be a more elegant solution.  The only thing that occurs to me would be to just loop through the decimal integers 1–32768 and convert those to binary, and use the binary representation as a filter to pick out the appropriate numbers.   Does anyone know of a better way? Using map(), maybe?
57815
There was a problem in a recent programming competition which my friend solved by assuming the following conjecture:     Show that for any set of $2n$ integers, there is a subset of $n$ integers whose sum is divisible by $n$.   I have thought about this problem for a while but can't seem to prove it, but I couldn't come up with a counter-example either.    A similar problem has a well-known solution: show that for any set of $n$ integers, there is a non-empty subset whose sum is divisible by $n$.  The proof goes as follows. Suppose the set is $\{x_1, x_2, \dots, x_n\}$ and hence define $s_i = \left(x_1 + x_2 + \dots + x_i\right)\bmod n$, with $s_0 = 0$. Then we have the set $\{s_0, s_1, \dots, s_n\}$ with $n+1$ elements, but each $s_i$ can take only $n$ distinct values, so there are two $i, j$ with $i\neq j$ such that $s_i = s_j$. Then $s_j - s_i = x_{i+1} + x_{i+2} + \dots + x_j$ is divisible by $n$.  However, this approach can't directly be applied to this problem since now we need to ensure that we choose exactly $n$ integers.
108774
I would like to know if my answers are all correct, if someone willing to check it it will be greatly appreciated ...Thanks!😊  Universal/Union = { a,b,c,d,e,f,g,h}  A = {a,b,c,d}             A' = {e,f,g,h}  B = {e,f,g,h}.             B' = {a,b,c,d}  C = {a,d,h}                C' = {b,c,e,f,g}  D = {c,d,f,g}              D' = {a,b,e,h}  E = {a,b,c,f,g,h}         E' = {d,e}  Sets:  1.)[ [ [(A' ∩ B')' ∩ (C' ∩ D')']' - [(B-D')'- (A-C')']' ]' - E ]'  2.) [ [ [ [ (A' - B')' -C' ]' - D' ]' - E' ]' ∩ [ ( A' ∪ B')' ∩ (E' ∩ D')' ]' ]' ∩ ( B' '- C' ')' '  3.)[ B' ∩ [ (B' ∪ C')' - ( D' ∩ D)' ] ' ]' ∩ [( E ∪ E')' ∩ (C' - E)']'  Answer no. 1   A' ∩ B' = { }  (A' ∩ B')' = {a,b,c,d,e,f,g,h}   C' ∩ D' = {b,e}  (C' ∩ D')' = {a,c,d,f,g,h}  (A' ∩ B')' ∩ (C' ∩ D')'= {a,c,d,f,g,h}  [(A' ∩ B')' ∩ (C' ∩ D')']' = { b,e}  B - D' = {f,g}  (B - D')' = {a,b,c,d,e,h}  A - C' = {a,d}  (A' - C')' = {b,c,e,f,g,h}  ( B - D')' - (A - C')' = {a,d}  [(B - D')' - (A - C')']' = {b,c,e,f,g,h}  [( A' ∩ B')' ∩ (C' ∩ D')']' - [( B - D')' - (A - C')']' = { }  [[ (A' ∩ B')' ∩ (C' ∩ D')']' - [( B - D')' - (A - C')']']' = {a,b,c,d,e,f,g,h}  [[ (A' ∩ B')' ∩ (C' ∩ D')']' - [( B - D')' - (A - C')']']' - E = { e,d}  Final Answer:  [ [[ (A' ∩ B')' ∩ (C' ∩ D')']' - [( B - D')' - (A - C')']']' - E ]' = {a,b,c,f,g,h}  Answer no. 2   A' - B' = { }  (A' - B')' = {a,b,c,d,e,f,g,h}   (A' - B')' - C' = {a,d,h}  [(A' - B')' - C']' = {b,c,e,f,g}  [(A' - B')' - C']' - D' = {c,f,g}  [ [(A' - B')' - C']' - D' ]' = {a,b,d,e,h}  [ [(A' - B')' - C']' - D' ]' - E' = {a,b,h}  [ [ [(A' - B')' - C']' - D' ]' - E' ]' = {c,d,e,f,g}  A' ∪ B' = {a,b,c,d,e,f,g,h}  (A' ∪ B')' = { }  E' ∩  D' = {e}  (E' ∩ D')' = { a,b,c,d,f,g,h}  (A' ∪ B')' ∩ (E' ∩ D')' = { }  [(A' ∪ B')' ∩ (E' ∩ D')']' = {a,b,c,d,e,f,g,h}  [ [ [(A' - B')' - C']' - D' ]' - E' ]' ∩ [(A' ∪ B')' ∩ (E' ∩ D')']' = {c,d,e,f,g}  [ [ [ [(A' - B')' - C']' - D' ]' - E' ]' ∩ [(A' ∪ B')' ∩ (E' ∩ D')']' ] ' = {a,b,h}  *I cancel out  B' ' - C ' '   (B - C)' = {a,b,c,d,h}  [(B - C)']' = {e,f,g}  Final Answer:  [ [ [ [(A' - B')' - C']' - D' ]' - E' ]' ∩ [(A' ∪ B')' ∩ (E' ∩ D')']' ] ' ∩ [(B - C)']' = { }   Answer no. 3   B' ∪ C' = {a,b,c,d,e,f,g}  (B' ∪ C')' = {h}  D' ∩ D = { }  (D' ∩ D)' = {a,b,c,d,e,f,g,h}  (B' ∪ C')' - (D' ∩ D)' = { }  [(B' ∪ C')' - (D' ∩ D)']' ={ a,b,c,d,e,f,g,h}  B' ∩ [(B' ∪ C')' - (D' ∩ D)']' = {a,b,c,d}  [ B' ∩ [(B' ∪ C')' - (D' ∩ D)']' ]' ={e,f,g,h}  E ∪ E' = {a,b,c,d,e,f,g,h}  (E ∪ E')' = { }  C' - E = {e}  (C' - E)' = {a,b,c,d,f,g,h}  (E ∪ E')' ∩ (C' - E)' = { }  [ (E ∪ E')' ∩ (C' - E)' ] ' = {a,b,c,d,e,f,g,h}  Final Answer:  [ B' ∩ [(B' ∪ C')' - (D' ∩ D)']' ]' ∩ [ (E ∪ E')' ∩ (C' - E)' ] ' = { e,f,g,h}
119103
Omg this is driving me crazy seriously, it's a subproblem for a bigger problem, and i'm stuck on it.  Anyways i need the number of ways to pick $x[1]$ ammount of objects type $1$, $x[2]$ ammount of objects type $2$, $x[3]$ ammounts of objects type $3$ etc etc such that $$x[1] + x[2] + \ldots x[n] = k\;.$$ Order of the objects of course doesn't matter.  I know there is a simple formula for this something like $\binom{k + n}n$ or something like that i just can't find it anywhere on google.
41981
For example, if n = 2, and a = 3.5 one could have (1,6), (2,5), (3,3), (4,3), (5, 2), (6,1) = 6  if n = 10 and a =3.5, one possible combination could be (1, 6, 1, 6, 1, 6, 1, 6, 1, 6)
81524
Let $A$ be a set of $n$ elements. Then, in how many ways, can we choose an ordered pair $(B,C)$, where $B,C$ are disjoint subsets of $A$?  Let A={1}, then B can be {phi} and C can be {1}. So, one ordered pair.   Let A={1,2}, then B can be {phi}, {1} and C can be {1},{2}. So three ordered pairs.   Let A={1,2,3}. Then B can be {phi},{1},{2} and C can be {1},{2},{3}.   So six pairs ? Am I going in the right direction ?
82285
We can see subsets as combinations of unspecified length of a set's elements, and there are, of course,   $$\sum_{k=0}^n {n \choose k}=2^n$$   subsets of a set with $n$ elements.  I was wondering whether there is a neat expression (analogous to $2^n$) for  the number of permutations of unspecified length of the elements of a set.    For example, if we have five distinct items, the number of permutations for each possible length is given below; the total number of permutations (i.e., of unspecified length) would simply be the sum of these numbers.        Length of permutation | Number of permutations       ----------------------------------------------           0                 |    1           1                 |    5           2                 |    5⋅4           3                 |    5⋅4⋅3           4                 |    5⋅4⋅3⋅2           5                 |    5⋅4⋅3⋅2⋅1   Of course we can express the total number of permutations of unspecified length of $n$ items as $\displaystyle\sum_{k=0}^n {}_n\text P_k$ but is there is a neater expression that this sum evaluates to, or at least a conventional notation for this number?
4130
Python's  function returns the sum of numbers in an iterable.  sum([3,4,5]) == 3 + 4 + 5 == 12   I'm looking for the function that returns the product instead.  somelib.somefunc([3,4,5]) == 3 * 4 * 5 == 60   I'm pretty sure such a function exists, but I can't find it.
18193
How would one denote the set of all subsets of $A$ which have size $2$?  Would  $$\binom{A}{2}$$  be a good idea?
43812
Let's say I have numbers each taken in a set $A$ of $n$ consecutive naturals, I ask myself : how can I found what are all the unique multisets, which could be created with $k$ elements of this set $A$?  For example I've got $A=[1,2,\dots,499]$. If I wanted to create unique multiset of 3 elements, I would search all the multisets $\{a,b,c\}$ such as $a\leq b\leq c$ and then have all the unique multisets. As such for each elements $a$ there is $499-(a-1)=500-a$ possibilities for $b$ and $500-b$ possibilities for $c$. Unfortunately I'm stumped here and can't find the number of possible combination, as I didn't do any maths for years. I know that I should have some kind of product, but I don't know how to find the product anymore.  So first, I would like to know if I am right in my original assumption, or if I am looking in the wrong direction. Second I would like to approach that as if I were doing an homework, as I would like to understand the logic behind it: What would be the formula to give the numbers of multisets of $k$ elements from a set $A$ of $n$ consecutive naturals?  P.S. I'm totally new to math.SE, as such, I'm not sure I tagged the post appropriately.
9212
How to find an uncountable subset of $P(\mathbb{N})$ such that every two elements of it can be compared. In fact, give an uncountable subset of $P(\mathbb{N})$ such that has totality property. We mean by $P(\mathbb{N})$, the powerset of natural numbers set $\mathbb{N}$.
27339
What is the number of different partitions of the set N of integers? My reasoning thus far goes as follows: the number must be at least as big as ω because any given integer can be matched with any other integer in a single partition cell. The number must be greater than ω (the first infinite cardinal), because diagonalization kicks in as soon as you try to enumerate the set. But it can be no bigger than ω(2), because each partition is a collection of subsets of N and thus a subset of P(N) (the power set of N). Hence, the set of all partitions is a subset of P(P(N)). Therefore, given the continuum hypothesis, the number I am looking is either the first or the second uncountable ordinal. Any ideas?
23113
What's the difference?  What are the advantages / disadvantages of tuples / lists?
7527
How do I select the unique elements from the list {0, 1, 2, 2, 2, 3, 4, 4, 5} so that I get {0, 1, 3, 5}, effectively removing all instances of the repeated elements {2, 4}?
740
I have a list of arbitrary length, and I need to split it up into equal size chunks and operate on it. There are some obvious ways to do this, like keeping a counter and two lists, and when the second list fills up, add it to the first list and empty the second list for the next round of data, but this is potentially extremely expensive.  I was wondering if anyone had a good solution to this for lists of any length, e.g. using generators.  I was looking for something useful in itertools but I couldn't find anything obviously useful. Might've missed it, though.  Related question:
119250
Given a set of whole numbers of size $n$, how many unique combinations of these whole numbers are there?   For example, for the set $\{1,2,3\}$ the unique combinations are   $\{1,2,3\}, \{1,2\}, \{1\}, \{2\}, \{3\}, \{2,3\}, \{1,3\}$   The number of combinations for $\{1,2,3\}$ is $7$.  Does this generalize to the number of unique combinations in a set is $2^n-1$ where $n$ is the number of elements in the set?
69796
Let $X = \{A_1,A_2,... ,A_n\}$ be a set of distinct $3$-element subsets of $\{1, 2,... , 36\}$ such that  i) $A_i$ and $A_j$ have non-empty intersection for every $i,j$.  ii) The intersection of all the elements of $X$ is the empty set.  Show that $n ≤ 100$. How many such sets $X$ are there when $n = 100$?  Source:  BMO 2005 round 2 question.  Please help !! I am not even able to proceed with the question I tried to come up with a recurrence relation but its not working. I have only been able to figure out the number when 36 is replaced by 6, which is an easy thing to do