How can we customize the code with rand() function in order to generate a n-digit number, where n&lt;8, without digit duplicates in it? Suppose I want to generate a 4 digit number from 1000 to 9999, this number should not contain digit duplicates: for instance 1023 4798, etc. Btw, we may not generalize n. Edits I skimmed through the answers in the question I was adressed to. I honestly think that the problem of generating a sequence of digits without a single duplicate in it is in my opinion easier that generating a number with no duplicate digits. Still looking for an answer. My code is a real mess and truthfully does not contain a single try to tackle the stated problem. I have a paper draft but still it's based on assigning an integer variable to each digit in a number and a small loop which checks if some of them are equal and increment/decrements one of them. This sounds like a bad idea even to me, but this is all I can come to.
Duplicate:    I want an pseudo random number generator that can generate numbers with no repeats in a random order. For example: random(10) might return 5, 9, 1, 4, 2, 8, 3, 7, 6, 10 Is there a better way to do it other than making the range of numbers and shuffling them about, or checking the generated list for repeats?  Edit: Also I want it to be efficient in generating big numbers without the entire range.  Edit: I see everyone suggesting shuffle algorithms. But if I want to generate large random number (1024 byte+) then that method would take alot more memory than if I just used a regular RNG and inserted into a Set until it was a specified length, right? Is there no better mathematical algorithm for this.
What is the difference between new/delete and malloc/free?  Related (duplicate?): Find the area of largest rectangle that can be inscribed in an ellipse The actual problem reads:      Find the area of the largest rectangle that can be inscribed in the ellipse    $$\frac{x^2}{a^2} + \frac{y^2}{b^2} = 1.$$   I got as far as coming up with the equation for the area to be $A=4xy$ but then when trying to find the derivative I don't think I'm doing it right. What does a Terminator do after its mission is accomplished? A Terminator is essentially given a mission or an objective ("Go back in time and kill Sarah Connor" or something of the like).  What does a Terminator do once its mission is accomplished?  We see in Terminator 2: Judgment Day (the live-action movie) that the  (played by Arnold Terminator Schwarzenegger) completed its mission of protecting the Connors, and then sort-of just melted itself into nothingness (presumably to protect the world from discovering Terminators again).  But what would the  or the  (in Terminator 3) have done?   Are they given multiple directives ("Go kill Sarah Connor, then go kill Robert Baratheon, and then have a nice hot bath; you've earned it")?  This question is related, but not a dupe: Normal + Connected -> Uncountable Here's a solution (to the exercise "prove that if $X$ is a space with more than one element, and is normal and connected then $X$ is uncountable"):   by Urysohn's lemma, given $A$ and $B$, closed and disjoint in $X$, there exists a continuous function from $X$ into $[0,1]$ such that $f(A)={0}, f(B)={1}$.   If $X$ were countable, so it would be $f(X)\subset [0,1]$; choose $r\in (0,1)\setminus f(X)$, then $X=f^{-1}([0,r))\cup f^{-1}((r,1])$, so $X$ is disconnected.  But the full power of the lemma wasn't used, all that was used is that there exists a continuous function $X\longrightarrow [0,1]$, so the condition of being normal seems too much.  So my question is, what are the weakest conditions on $X$ for the existence of such continuous functions into $[0,1]$ (or $\mathbb{R}$, for that matter)? Install suspension forks on non-suspension bike I have a 1990s Saracen PowerTrax. Is there a way I can install a suspension fork, or will that muck up the bike somehow? I'm actually interested in ways to raise the bars with respect to the seat, so that wouldn't be a problem. My toes rubbing in the wheel, in the other hand, would definitely be a problem. CSS 100% height with padding/margin With HTML/CSS, how can I make an element that has a width and/or height that is 100% of it's parent element and still has proper padding or margins?  By "proper" I mean that if my parent element is 200px tall and I specify height = 100% with padding = 5px I would expect that I should get a 190px high element with border = 5px on all sides, nicely centered in the parent element.  Now, I know that that's not how the standard box model specifies it should work (although I'd like to know why, exactly...), so the obvious answer doesn't work:  #myDiv {     width: 100%     height: 100%;     padding: 5px; }   But it would seem to me that there must be SOME way of reliably producing this effect for a parent of arbitrary size. Does anyone know of a way of accomplishing this (seemingly simple) task?  Oh, and for the record I'm not terribly interested in IE compatibility so that should (hopefully) make things a bit easier.   EDIT: Since an example was asked for, here's the simplest one I can think of:  &lt;html style="height: 100%"&gt;     &lt;body style="height: 100%"&gt;         &lt;div style="background-color: black; height: 100%; padding: 25px"&gt;&lt;/div&gt;     &lt;/body&gt; &lt;/html&gt;   The challenge is then to get the black box to show up with a 25 pixel padding on all edges without the page growing big enough to require scrollbars. I am trying to slice up my models using the Boolean modifier.  After applying the modifier on my smooth mesh, I get the expected result, a flat dissection to separate my mesh into two.  The problem lies in how I can resolve the visual "jaggered" edge that separates my (smooth) mesh exterior from the flat dissection face.    Is it possible to achieve a smooth-to-flat variation without this artifact?   I tried to alter a mixture of the two but end up with artifacts, or unwanted blocky flat mesh faces around the dissection edge of my mesh. Why does \cal{M}_n give “M>”? Global setting of hyphenation for words containing dashes Adding only specific text from a file to an array list, part 2 - Java This is tricky. I would like to install Ubuntu on a machine that is intended to work as server, and for some reason I do not have an option to connect a screen to it.  I expect this may be similar to remote installation. However, there is currently no OS on that machine, so I will have to set up everything from scratch.  On the other hand, I do have a physical access to that machine. Therefore I can get it to boot from a CD/USB. But that's not enough.  Is there a way to do such installation remotely? Is there a version of Ubuntu image that comes with a SSH server preinstalled, and starts it once booted, so that I can boot the machine with such image, connect to it via SSH and process the installation from a different computer?  If not, what other options do I have? Completing a 3x3 correlation matrix: two coefficients of the three given I was asked this question in an interview.  Lets say we have a correlation matrix of the form \begin{bmatrix}1&amp;0.6&amp;0.8\\0.6&amp;1&amp;\gamma\\0.8&amp;\gamma&amp;1\end{bmatrix}  I was asked to find the value of gamma, given this correlation matrix. I thought I could do something with the eigenvalues, since they should be all greater than or equal to 0.(Matrix should be positive semidefinite) - but I don't think this approach will yield the answer. I am missing a trick.  Could you please provide a hint to solve for the same? Wilson and Fermat's Theorem Question!     Show that the pair of positive integers $n$ and $n+2$ are twin primes if and only if $$4[(n-1)! + 1] + n = 0 \ (\text{mod} \ n(n+2)),$$ where $n$ does not equal $1$. What will be the one's digit of the remainder in: $\left|5555^{2222} + 2222^{5555}\right|\div 7=?$ What will be the ones digit of the remainder in: $$\frac{\left|5555^{2222} + 2222^{5555}\right|} {7}$$ What features of Mavericks are beneficial to you? This question serves to share and collect the enhancements that make a large difference to how you use your Mac.   Please post one feature per answer. Please also check to see if your answer has already been posted - duplicate answers will be deleted. To search answers for this question use  (directly from the question page) in addition to your search terms in the search box in the upper right hand corner of this page.  The best answers will not only list a feature, but provide details on how to configure that feature, and provide an image of how to use the feature to be more efficient or effective with Mavericks. I would like to use multiple .bib files for my article, such as file1.bib, file2.bib. However, I would like my references not to be separated (such as &quot;Primary sources&quot;, &quot;Secondary sources&quot;, etc.). These bibliographies just need to be merged into one. One way to do this is to copy-paste these .bib files into one .bib file, and this would solve the problem. However, I would like to keep it split into several .bib files, by topic (file1.bib contains articles on topic1, file2.bib contains articles on topic2, and so on). I tried to do \bibliographystyle{alpha}  \bibliography{file1} \bibliography{file2}  but this just gives me the same bibliography twice! Modifying C string constants? I am using a tikzpicture for plotting. the values I want to plot are typical (X,Y) pairs. The x-value is an uninteresting id-value. I want to order the bins ascending/descending according to the y-value, but how do I do that? The figure seems to automatically take the x-values for ordering, how can I override that? (I am not particularly fixed to tikzpicture - its just the first thing that actually worked and displayed the plot....) Following minimal-working example, how could I achieve a reordering according to the y-value?  \documentclass{article} \usepackage[english]{babel} \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} \usepackage{relsize} \usepackage{times} \usepackage{url} \usepackage{latexsym} \usepackage{graphicx} \usepackage{colortbl} \usepackage{color} \usepackage{caption} \usepackage{pgfplots, pgfplotstable} \usetikzlibrary{arrows} \usepackage{amsmath} \usepackage{multirow} \usepackage{booktabs}  \usepackage{filecontents} \definecolor{OgAns}{rgb}{0, 0.8, 0.4}  \begin{filecontents}{testdata.dat} 1   30 2   44 4   26 3   39 \end{filecontents}  \begin{document} \begin{figure} \begin{tikzpicture}         \begin{axis}[                ybar stacked,             ymin=0,             ymax=100,             bar width=5pt,             legend style={at={(0.35, -0.4)},anchor=south west},             legend columns=-1                       ]           \addplot[ybar,fill=OgAns]  file {testdata.dat};          \end{axis}     \end{tikzpicture} \end{figure}   \end{document} I am creating table in LaTeX and I need to get the text to perform line break automaticaly when it's too long. And if possible, I'd like to get the text alignment to the left. Is it possible to handle this situation? Why don't Jedi (or Sith) use the Force to snap their foes' necks? I understand that the Jedi use the Force for self defence, but still, couldn't they just use the Force to snap their foes' necks and be done with it? Like when Jaina Solo was hunting down Darth Caedus. Or even when Caedus was duelling Grand Master Skywalker. If he just used the Force to snap Skywalker's neck (like he did to poor Lieutenant Tebut), it will all be over very fast.  Is there a canon reason why Jedi and Sith don't use their powers to directly harm their opponents?