I have an issue with comparing Strings that sometimes contain numbers.   Let's say I have two Strings; s1 = "Chapter 9" and s2 = "Chapter 10"  Any human would say that, if these are to be sorted, s1 would end up earlier than s2 and that also happens in Windows folders. However, in Java it just checks one char at a time until one is greater/lesser than the other, which leads to it putting s2 earlier than s1 due to it having a '1' where s1 has a '9'  Is there a way of managing this that does not involve a lot of code and/or processing?
I need to write a Java Comparator class that compares Strings, however with one twist.  If the two strings it is comparing are the same at the beginning and end of the string are the same, and the middle part that differs is an integer, then compare based on the numeric values of those integers.  For example, I want the following strings to end up in order they're shown:   aaa bbb 3 ccc bbb 12 ccc ccc 11 ddd eee 3 ddd jpeg2000 eee eee 12 ddd jpeg2000 eee   As you can see, there might be other integers in the string, so I can't just use regular expressions to break out any integer.  I'm thinking of just walking the strings from the beginning until I find a bit that doesn't match, then walking in from the end until I find a bit that doesn't match, and then comparing the bit in the middle to the regular expression "[0-9]+", and if it compares, then doing a numeric comparison, otherwise doing a lexical comparison.  Is there a better way?  Update I don't think I can guarantee that the other numbers in the string, the ones that may match, don't have spaces around them, or that the ones that differ do have spaces.
Pairwise independence of Random variables does not imply indendence Show by a counterexample that for a family $(X_i)_{i\in I}$ of random variables the independence of all pairs $(X_i,X_j)$ with $i,j\in I, i\neq j$ does not imply the independence of the family (It is enough to consider $\mbox{card}(I)=3$.).      Hello, I am searching for a simple example. The professor gave the hint that one might consider random variables which only can take two different values, but I do not know exactly what is meant.  By the way:  We call the family $(X_i)_{i\in I}$ of random variables independent, if $(\sigma(X_i))_{i\in I}$ is independent, whereat we call a family $(\mathcal{E}_i)_{i\in I}$ with $\mathcal{E}_i\subset\mathcal{A}$ independent, if for any finite subset $I_0\subset I$ and any choice $E_i\in\mathcal{E}_i, i\in I_0$, it is $$ \mathbb{P}(\bigcap_{i\in I_0}E_i)=\prod_{i\in I_0}\mathbb{P}(E_i). $$ When has Wonder Woman died? I know Wonder Woman has died in canon before, but in which issue did this happen? Pgfplots: how to fill bounded area under a curve using addplot and fill? Let $\{s_n\}$ and $\{t_n\}$ be sequences.  I've noticed this inequality in a few analysis textbooks that I have come across, so I've started to think this can't be a typo:  $\limsup\limits_{n \rightarrow \infty} s_n + \liminf\limits_{n \rightarrow \infty} t_n \leq \limsup\limits_{n \rightarrow \infty} (s_n + t_n) \leq \limsup\limits_{n \rightarrow \infty} s_n + \limsup\limits_{n \rightarrow \infty} t_n$.  I understand the right two-thirds of the equation, and can prove it.  I'm stuck on the far-left third.  I don't understand how that is true. Logitech SetPoint software button remapping My Logitech G5 Laser mouse has 9 buttons but it's SetPoint software only allows 5 of them to be used as "mouse buttons" and the remaining 4 can only be assigned special windows functions (Forward, Back, Cruise Up, etc) or Keystroke Assignments.  Many of the games I play will take up to 10 "MOUSE BUTTON" inputs for in-game actions but wont recognize the remaining 4 buttons even when assigned keystroke assignments.  Is there a way to make these last 4 buttons "Generic Buttons" as well as buttons 3,4,and 5? (1 is left click and 2 is right click).  My other question is if the above is not possible, maybe I can use AutoHotkey to remap keystrokes as assigned by my SetPoint software to mouse button commands?  If so how? Gimp won't allow me to copy and paste a transparent image On the latest version of GIMP on my PC, whenever I try to copy a transparent image from the internet, GIMP will automatically fill in the transparent areas with the background color I have selected.  This is a non-issue on my Mac, but I need to do this work on my PC, so how can I make it recognize the alpha of the image and not fill it with the background color?  The image canvas that I'm working with does have an alpha channel, but that does not seem to make a difference. What are tag synonyms and merged tags? How do they work? I have a multiboot system set up. The system has three drives. Multiboot is configured with Windows XP, Windows 7, and Ubuntu - all on the first drive. I had a lot of unpartitioned space left on the drive and was reserving it for adding other OSes and for storing files there in the future.  One day I went ahead and downloaded Partition Wizard and created a logical NTFS partition from within Windows 7, still some unpartitioned space left over. Everything worked fine, until I rebooted the computer a few days later.  Now I'm getting:    error: unknown filesystem.   grub rescue&gt;   First of all I was surprised not to find any kind of help command, by trying:    help, ?, man, --help, -h, bash, cmd, etc.  Now I'm stuck with non-bootable system. I have started researching the issue and finding that people usually recommend to boot to a Live CD and fix the issue from there. Is there a way to fix this issue from within grub rescue without the need for Live CD?  UPDATE  By following the steps from , I was able to boot to initramfs prompt. But not anywhere further than that.  So far from reading the manual on , I was able to see my drives and partitions using ls command. For the first hard drive I see the following: (hd0) (hd0,msdos6) (hd0,msdos5) (hd0,msdos2) (hd0,msdos1)  I now know that (hd0,msdos6) contains Linux on it, since ls (hd0,msdos6)/ lists directories. Others will give "error: unknown filesystem."  UPDATE 2  After the following commands I am now getting to the boot menu and can boot into Windows 7 and Ubuntu, but upon reboot I have to repeat these steps.    ls ls (hd0,msdos6)/ set root=(hd0,msdos6) ls / set prefix=(hd0,msdos6)/boot/grub insmod /boot/grub/linux.mod normal   UPDATE 3  Thanks Shashank Singh, with your instructions I have simplified my steps to the following. I have learned from you that I can replace msdos6 with just a 6 and that I can just do insmod normal instead of insmod /boot/grub/linux.mod. Now I just need to figure out how to save this settings from within grub itself, without booting into any OS.  set root=(hd0,6) set prefix=(hd0,6)/boot/grub insmod normal normal   UPDATE 4  Well, it seems like it is a requirement to boot into Linux. After booting into Ubuntu I have performed the following steps described in the :  sudo update-grub sudo grub-install /dev/sda   This did not resolve the issue. I still get the grub rescue prompt. What do I need to do to permanently fix it?  I have also learned that drive numbers as in hd0 need to be translated to drive letters as in /dev/sda for some commands. hd1 would be sdb, hd2 would be sdc, and so on. Partitions listed in grub as (hd0,msdos6) would be translated to /dev/sda6.  UPDATE 5  I could not figure out why the following did not fix grub:  sudo update-grub sudo grub-install /dev/sda   So I downloaded  based on an answer from  post. That seemed to do the trick after I picked the "Recommended Repair (repairs most frequent problems)" option. What are the uses of Unicorns? What different uses does the unicorn have?  Other than the delicious taste of them coming off the grill.   At Wit's End #221 Preview: PDF Highlighting & Search Stop Working until Restart A problem has recently become much more prevalent for me when using Preview to search PDFs for text (using Command + F or the search box in the upper right).  At first, everything generally seems to go fine:    (as it should be) a list of thumbnails appears in the sidebar, indicating all of the pages that contain the search term. Generally, though not always, the term I search for will be highlighted on the first page that it occurs on.   But, after this, things quickly start malfunctioning:   Generally speaking, if I click on thumbnails lower on the list, Preview will take me to that page in the PDF (like it used to).  But, it will no longer highlight the searched for terms. Instead, Preview will make a low-pitched beeping noise of the sort that occurs when one tries to perform some un-permitted action in a variety of mac situations. Furthermore, once this occurs, I cease being able to make any highlights at all in the document I am viewing with Preview.  In fact, I can't even select any text any more.   Below is a list of unsuccessful efforts to resolve this:   Closing the side bar does not work to resolve this. x-ing out the search box in the upper right does not resolve this. Selecting the "Tools" menu and then "Text Selection" does not work either, nor does clicking on the text selection icon in the edit panel. If I quit preview and then re-open the PDF, I am able to highlight again.  But, the problem will re-surface as soon as I try performing another search. Working with the same files in other PDF programs (e.g. Skim, Acrobat, etc.) poses no problems.  I'm quite certain it isn't a problem with the underlying PDFs. None of the responses to  resolve this.  (indeed, I supplied one such response myself a while ago, but that trick and the others no longer work).   I've used Preview for many years without problem.  This issue started cropping up relatively recently for me, I believe within the past 3-4 months.  I had hoped that upgrading to Catalina might resolve it, but it did not.    I'd like to think I am fairly sophisticated with computers (I have a reputation of close to 8,000 on the main stackoverflow page), but I am baffled by this.  I also don't have a good handle on how I can get diagnostic information or how I can create a reproducible example.    Any leads on how to tackle this would be greatly appreciated. Scaling HUD with variable resolution Uniform vs discrete Gaussian sampling in Ring learning with errors The Wikipedia article on  mentions two methods of sampling "small" polynomials namely uniform sampling and discrete Gaussian sampling. Uniform sampling is clearly the simplest, involving simply uniformly selecting the coefficients from the set of small coefficients, thereby guaranteeing they will be small. However, the articles mention that security proofs rely on discrete Gaussian sampling.  However, I have a bit of difficulty wrapping my head around    Why discrete Gaussian sampling would be better than uniform, security-wise?   I mean, usually uniform is preferable - it maximizes the entropy/information in each sample, making the outcome more unpredictable. I could understand it if the Gaussian sampling technique would somehow serve to avoid (at least with high probability) "weak" parts of the space of outcomes but I have found no information/justification that this is the case.  Another reason I can see why discrete Gaussian might be better is that there is, after all, a chance (albeit a small one) one would select a non-small coefficient, so the space of outcomes is actually larger. However, given that this probability of hitting this extra space is (by design) quite small but also that one would likely immediately reject such a sample (because the algorithm calls for a small polynomial), this seems to be irrelevant.  It is not because I am against discrete Gaussian sampling I just want to understand why it is more secure. Also, I want to understand if it really IS more secure or it is simply easier to prove security in that model. I would actually consider that very interesting if it is the case because it raises the question of why is it easier to prove the security under conditions that are intuitively worse (i.e. discrete Gaussian vs the intuitively better uniform case)? If it is so intuitively clear that uniform sampling is better, surely it must be possible to transform that intuition into a security proof of RWE also under uniform sampling. Otherwise, I would fear the intuition must with high likelihood be wrong or at least dubious. Nielsen & Chuang Exercise 2.2 - “Matrix representations: example” Reproduced from Exercise 2.2 of Nielsen &amp; Chuang's Quantum Computation and Quantum Information (10th Anniversary Edition):     Suppose $V$ is a vector space with basis vectors $|0\rangle$ and $|1\rangle$, and $A$ is a linear operator from $V$ to $V$ such that $A|0\rangle = |1\rangle$ and $A|1\rangle = |0\rangle$. Give a matrix representation for $A$, with respect to the input basis $|0\rangle, |1\rangle$, and the output basis $|0\rangle, |1\rangle$. Find input and output bases which give rise to a different matrix representation of $A$.   Note: This question is part of a series attempting to provide worked solutions to the exercises provided in the above book. Covariance of a variable and a linear combination of other variables Let $X,A,B,C,D$ be time-series variables and the covariance between any two pairs of these are known.  Suppose we want to find $\textrm{cov}(X,aA + bB + cC + dD)$, where $a,b,c,d$ are constants.  Is there any way of doing this without expanding out $E[(X-E[X])(aA+......)]$? Is "princessship" a real word? Are there any other words which have the same letter 3 times consecutively? Switch off Windows Update for a particular program or feature I'm getting really tired of unchecking the same Windows Update candidates so save hundreds of MB's of dowbloads, especially for programs I never use, that are in fact not even installed, and those I don't wish to update.  Is there any way to permanently, or until another explicit change, to turn off certain updates?  There is an option called 'Hide update', but that unsettles me a bit. In plain English, how does casting spells and using creature abilities work with the stack and priority? I'm a relatively new player to Magic: the Gathering. I was reading  to try to understand exactly when it's okay to cast instants (e.g. ) and use some abilities (e.g.  should be tappable sometime during other peoples' turns), but I don't seem to be making much progress: as I come to understand some things, others make less sense.  My confusion is boundless  For instance: to cast  one needs priority. Spells go on the stack, and priority gets passed at some points (I have no idea when), and effects on the stack are resolved when both players have passed priority. But when is that? I can't find any mention of when the other player gets the priority to cast an instant, except on their own turn. Furthermore,  states that during the Main Phase:     505.4. Second, the active player gets priority. Players may cast spells and activate abilities. The active player may play a land.   So players (plural) may cast spells, but only the active player has priority, so only the active player can cast an instant. The turn rules, and the rules on , never mention any point at which the other player gets priority, so when can they possibly Cancel?  In addition, you can only cast a spell when the stack is empty, so the entire stack must be able to be resolved in your turn at some point.  I need an explanation!  I could go on a bit more. There is also  which can be overloaded to "Counter each spell you don't control", which seems like it could only possibly work with an understanding of the stack.  Could someone explain, in simple English:   When can Instants be cast? When can tap abilities be used? What do Instants and abilities have to do with the Stack and Priority? How to compute $\int_0^{\pi/2}\frac{\sin^3 t}{\sin^3 t+\cos^3 t}dt$? Calculating with Mathematica, one can have $$\int_0^{\pi/2}\frac{\sin^3 t}{\sin^3 t+\cos^3 t}\,\mathrm dt=\frac{\pi}{4}.$$   How can I get this formula by hand? Is there any simpler idea than using $u = \sin t$?     Is there a simple way to calculate $$ \int_0^{\pi/2}\frac{\sin^n t}{\sin^n t+\cos^n t}\,\mathrm dt $$ for $n&gt;3$? Could anyone come up with a reference for this exercise? I want to do this using the Math.Round function The swarms of dead men fighting for the good side always seemed wrong to me. I know they did it to be released from their plight, but.... It's one thing to curse somebody, it's quite another to back it up. How did Isildur back up his curse on the oath breaking men of Dunharrow?