Getting all the combinations in a list lets say I have a list [1,1,1,1].  I want to iterate over all the possible combinations while every index of the list must contain a number from 1 to n.  in other words, i want to make a for loop that will go over all the combinations.  like: [n-35, n-5, 1, n], [1, 1, 1, n], [n, 1, n, n-19]. I hope you get the idea.  does anyone has any idea how to do this?
How to get all possible combinations of a list’s elements? 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?
How to suppress scientific notation when printing float values? Here's my code:  x = 1.0 y = 100000.0     print x/y   My quotient displays as 1.00000e-05.  Is there any way to suppress scientific notation and make it display as 0.00001? I'm going to use the result as a string. This question is pretty simple: I'd like to have the possibility to get the exact size of a picture in LaTeX with, for example, the macro \the.  In fact, I've founded the way \settoheight{} and so on, but it didn't work at all. What I've got doesn't match with what I can see in the image properties (I suppose that's the name in English). The result: 8pt versus 1300 pixels. It's may be a mis-use...  Edit: In the end, my aim was to find a way to fit the picture in LaTeX. If width and height were both less than the dimensions of the body, then it should just be centred. It look like this :     Require:   \usepackage{graphicx} \usepackage{xifthen} \usepackage{calc}   Code (pretty ugly, I agree):   % Centrering+fitting for image, with captation and label (not auto) \newlength\imageheight \newlength\imagewidth \newcommand{\pic}[3]{% \settoheight\imageheight{\includegraphics{pictures/#1.png}}% \settowidth\imagewidth{\includegraphics{pictures/#1.png}}% \ifthenelse{\lengthtest{\imagewidth &gt; \textwidth}}{\ifthenelse{\lengthtest{\imageheight &gt; \imagewidth}}{\par\vspace{0.95em}% \begin{figure}     \centering\includegraphics[height=0.85\textheight]{pictures/#1.png}     \caption{#2}     \label{#3} \end{figure}% \par\vspace{0.95em}}{\par\vspace{0.95em}% \begin{figure}     \centering\includegraphics[width=0.95\textwidth]{pictures/#1.png}     \caption{#2}     \label{#3} \end{figure}% \par\vspace{0.95em}}}{\ifthenelse{\lengthtest{\imageheight &gt; \textheight}}{\par\vspace{0.95em}% \begin{figure}     \centering\includegraphics[height=0.85\textheight]{pictures/#1.png}     \caption{#2}     \label{#3} \end{figure}% \par\vspace{0.95em}}{\par\vspace{0.95em}% \begin{figure}     \centering\includegraphics{pictures/#1.png}     \caption{#2}     \label{#3} \end{figure}% \par\vspace{0.95em}}}} %   To use it : put your png files in a "pictures" directory, then, just simply call the picture like this : \pic{name_whitout_extension}{Captation_if_needed}{Label_if_needed}.    Edit 2 :   Thanks to Martin Scharrer's easyfig package, I've got a more or less 1,6 times faster solution to put my pictures, centred, with the perfect size.  CTAN:   VC:   Version v1.2 – 2012/05/15    This could be useful for some others, I hope. How to restore file copy / transfer status window? Separate Network Traffic on Two Network Interfaces Tabs in Chrome Browser shrink too much Let $Z_i,Z_2,\ldots$ be IID Random Variables with density $f$. Suppose that $P(Z_i&gt;0)=1$ and that $\lambda=\lim_{x \to 0+} f(x)&gt;0$. How can I show that $X_n=n \times \min\{Z_i\}$ has a limiting exponential distribution with mean$1/\lambda$?  I know that the CDF of the first order Statistic is for $t&gt;0$  $$F_{min \{ Z_i \}} (t)= 1- \left[ 1-F(t) \right]^{n}$$  Convergence in distribution requires that $F_n (t) \to F(t)$ for some distribution function $F$ but I cannot quite take the limit of the above, with $t$ replaced by $x/n$, as the distribution is not known. I guess I have to insert the second piece of information somewhere but I do not recognise where.  Could you please give me a hint or two?  Thank you. Which Stack Exchange website for machine learning and computational algorithms? I'm currently working on many machine learning and computational algorithms, such as Singular Value Decomposition, Support Vector Machines, and others.  I'd like to ask questions about these topics, but I don't know which Stack Exchange website to use to post my questions.   Should I use ? Should I use ? Should I use ? Should I use ?   How do I tell?  What criteria do I use? I remember coming across this fact a while ago in a pdf somewhere, but I haven't been able to find it again. Can someone show me how to prove it? I would appreciate easier proofs.  EDIT: I'm very sorry, I forgot to actually state it.  Prove that $-1$ is not a quadratic residue modulo primes of the form $4k+3$.  Thanks! I would appreciate it if someone could refer me to a proof (or simply give one here) for the statement in the title. That is:  If $k&lt;n$, then every $k-$dimensional subspace of $\mathbb{R}^{n}$ has $n-$dimensional Lebesgue measure zero.  I've seen some proofs that use Sard's lemma but I'm not really familiar with that subject and I've never seen a proof of said lemma so I'd appreciate a proof that doesn't use it if possible.  Thanks in advance! What happens to the holes in the skull where teeth were developing? In Skeptics.SE, a question regarding the skulls of children arose. Depicting a scary skull where the permenent teeth are "hidden" inside the jaws and the milk teeth are in the their place.  After all milk teeth fall out, and the permanent teeth "rise", do the holes left by them filled up, or do we go around with holes in our jaws?    The picture: I recently moved into an in-law unit of a large old house.  In the kitchen, there are two pipes coming out of the wall (one protruding out a little more than the other).  I had assumed they were gas lines to connect my stove.  But since the stove only connects to one pipe, I'm now wondering if they're actually water lines. Can anyone explain how I can tell the difference? On the other side of the wall is a large closet with the air conditioning system, water heater, and what I think is the gas shutoff valve. "An hour" or "a hour" I have a number of measurements of the same quantity (in this case, the speed of sound in a material). Each of these measurements has their own uncertainty.  $$ v_{1} \pm \Delta v_{1} $$ $$ v_{2} \pm \Delta v_{2} $$ $$ v_{3} \pm \Delta v_{3} $$ $$ \vdots $$ $$ v_{N} \pm \Delta v_{N} $$  Since they're measurements of the same quantity, all the values of $v$ are roughly equal. I can, of course, calculate the mean:  $$ v = \frac{\sum_{i=1}^N v_{i}}{N}$$  What would the uncertainty in $v$ be? In the limit that all the $\Delta v_i$ are small, then $\Delta v$ should be the standard deviation of the $v_i$. If the $\Delta v_i$ are large, then $\Delta v$ should be something like $\sqrt{\frac{\sum_i \Delta v_i^2}{N}}$, right?  So what is the formula for combining these uncertainties? I don't think it's the one given in  (though I may be wrong) because it doesn't look like it behaves like I'd expect in the above limits (specifically, if the $\Delta v_i$ are zero then that formula gives $\Delta v = 0$, not the standard deviation of the $v_i$). Which of these sentences is correct?     Rupees are interchangeable with dollars   or      Rupees is interchangeable with dollars. Was Luke aware the Emperor was a Sith Lord? Similar to , I'm asking the more specific question, was Luke aware that the Emperor was a Sith Lord? I don't recall it being mentioned in any of the films.  If yes, at what point does he learn this? If not why did Yoda or Obi-Wan not warn him?  Perhaps he could have avoided being defenseless and struck by Force Lightning if he'd been made aware? Gauss's Lemma for polynomials claims that a non-constant polynomial in $\mathbb{Z}[X]$ is irreducible in $\mathbb{Z}[X]$ if and only if it is both irreducible in $\mathbb{Q}[X]$ and primitive in $\mathbb{Z}[X]$.   I wonder if this holds for multivariable case.      Is it true that a non-constant polynomial in $\mathbb{Z}[X_1,\dots,X_n]$ is irreducible in $\mathbb{Z}[X_1,\dots,X_n]$ if and only if it is both irreducible in $\mathbb{Q}[X_1,\dots,X_n]$ and primitive in $\mathbb{Z}[X_1,\dots,X_n]$?    Thank you for your help. What would be the quickest way to construct a Python binding to a C or C++ library?  (I am using Windows if this matters.) MSO Review Queue Privileges are Misleading How to make the simple three square box and connect them? I want to make the three square box and simply connect them. How do I debug when the system freezes or when it crashes back to login? I am fairly new to Ubuntu and I was wonder what a good way is to debug when something crashes?   For example: I installed 11.04 and the default media player banshee makes my laptop crash after a few minutes of playing music. Since the system completely freezes and there is not error message it's hard to find out what is wrong.  Second problem I have is that sometimes the system crashes to login. I am suspecting it to be a Chromium or Flash but I am not 100% sure.  So anybody got some tips on how to debug stuff like this?