Sort a list according to a property java
How do I remove repeated elements from ArrayList?
Fundamental group of the torus I'm trying to get my head round the following calculation of the fundamental group of the torus, using Seifert Van-Kampen (I know it's easier to do this by considering covering spaces, but I'm trying to learn the Seifert Van-Kampen method).   Consider the torus $T$ as the unit square in $\mathbb R^2$ with opposite edges identified. Let $A$ be an open disc (say of radius $1/4$ about the origin), and $\overline{A}$ be it's closure. Let $B$ be complement of $A$, so that $A \cap B = S^1$. Then we have $T = A \cup B$ where $A$ and $B$ are a neighbourhood deformation retract pair, so we can use Van Kampen. It is clear that $\pi_1(A) = \{e \}$ and $\pi_1(A \cap B) = \mathbb Z$. So we need to find $\pi_1(B)$. Observe that $B$ deformation retracts onto the boundary of the square which, after identification, is homeomorphic to $S^1 \vee S^1$; in this way we see that $B$ and $S^1 \vee S^1$ are homotopy equivalent (inclusion in one direction, the retraction in another), and so $\pi(S^1 \vee S^1) = F_2$ (which can be calculated by Van Kampen, or by using the theory of covering spaces). So, by Van Kampen, $\pi_1(T) \cong F_2 *_{\mathbb Z} \{e\}$. This is the quotient of $F_2$ by the normal closure of the image of $l_* : \pi_1(A \cap B) \to \pi_1(B)$ (where $l_*$ is the homomorphism induced from the inclusion map $l : A \cap B \hookrightarrow B$). The following is causing me confusion: The generator of $\pi_1(A \cap B)$ is homotopic in $B$ to a loop of the form $u.v.\overline{u}.\overline{v}$, where $u$ and $v$ represent the two generators of $F_2$. So $\pi_1(T) \cong \langle a,b ; aba^{-1}b^{-1} \rangle$, the free abelian group on two generators.  Any explanation or geometric intuition would be really appreciated. Thanks Canned reasons for up/down vote (w/ example of how it would work) I'm annoyed by down voters that don't explain why they down voted a question or an answer. Although, at the same time, I understand that they . I think there is a middle ground, though, where the voter can remain anonymous, while the poster can get aggregated feedback on ways to improve the post.  Rather than having to imagine what it might be like, the current stackoverflow engine can emulate this rather effectively with the use of comments and the up-voting of those comments (essentially saying "I agree"). So I thought I would give it a try. The only difference is that in this testing post, you will always see the list of "canned responses" where as in the complete version, it will most likely be hidden in a popup (e.g. when you hover over the score of an answer/question). To try it out, simply up or down vote this question (or one of its answers), and press the up arrow next to the comment which best describes why are voting that way. For example, if you hate this idea, give this a down vote, and then press the up arrow near -1: I don't like this idea.  In addition to retaining anonymity, this will also save time for the voter so that they don't need to write out the comment. This wouldn't be required, obviously, and there could be a default option selected don't leave a reason. In addition, there could be a custom option which allows you type exactly why you are down-voting this way. Depending on the final implementation, this could either simply be converted to a comment automatically prefixed with -1:  or +1:; or, to retain anonymity, it would be added to this same list that shows the canned responses and how many users have voted that way.  Here are some ideas for the canned responses:  Question:   +1: Well formatted and thought out question. -1: It doesn't seem like enough time was spent trying to solve this issue on your own. -1: I don't like this idea. (Could be especially useful on meta.stackoverflow.com feature-request.) -1: No prior research/work. (Idea from .) -1: Poor question. Please see . -1: Doesn't contain code. (This would be useful on stackoverflow.com. Idea from )   Answer:   +1: Concise. +1: Insightful. +1: Worked for me. -1: It's wrong. -1: Confusing. -1: Encouraging bad behavior (e.g. answering a question that shouldn't have been asked; see ).   I made this a community-wiki since there will probably be testing of up/down votes. Several of these canned responses have been taken from . This same idea was also . Following , I would like to know what exactly it means for a tag to be marked as blocked (formerly blacklisted) on a Stack Exchange site.  Does it mean I can't use that tag on my question? What are the reasons for blocking a tag? Who can block tags? Why am I being prompted to remove a tag from a question I'm editing? Performance of a Trigger vs Stored Procedure in MySQL I know that \: in LaTeX produces a space when rendered.  Are there any alternatives, because my LaTeX renderer doesn't support \: (it renders it as text), and there is no help / FAQ that I can find. How to download packages from a command-line given repository? Short circuit or disconnect to bypass a compressor Is there any built-in way to get the length of an iterable in python? For example, files, in Python, are iterable - they iterate over the lines in the file. I want to count the number of lines.   One quick way is to do this:  lines = len(list(open(fname)))   However, this loads the whole file into memory (at once). This rather defeats the purpose of an iterator (which only needs to keep the current line in memory).  This doesn't work:  lines = len(line for line in open(fname))   as generators don't have a length.  Is there any way to do this short of defining a count function?  def count(i):     c = 0     for el in i: c += 1     return c   To clarify, I understand that the whole file will have to be read! I just don't want it in memory all at once Are the "umbles" etymologically related? From      And we show telltale signs of early hypothermia, what the doctor and   the National Institutes of Health and other cold-weather cognescenti   call the "umbles."      First we lose some fine motor skills, McLaren says, "and we start to   fumble. And tumble. And stumble."      Then our cognitive abilities are compromised. "We mumble and we   grumble."   Are the "umbles", such as fumble, tumble, stumble, mumble and grumble, etymologically linked, either in terms of sharing a common ending, or entire words having a common ancestor?  Trying to do a search of the etymology of the umbles ended up giving the etymology of the word  instead. MacBook Pro (15-inch, 2016) with 2 USB-C to HDMI adapters. The setup works great if I start up in that configuration.   If I connect the adapters while the machine is running or simply sleeping, one of the monitors will never get a signal and stay in low power mode. The OS sees the monitor, it shows in the display arrangement settings and I can move the mouse into it, but until I restart, I can't see anything on it.  Once I have restarted I can let the machine sleep or whatever, and the display still works unless I disconnect the adapter. As soon as I do that a restart is required to use it again.   Using MacOS Sierra (10.12.4)  Using this adapter: Q: How many arrangements of a,a,a,b,b,b,c,c,c are there such that  $\hspace{5mm}$ (i). no three consecutive letters are the same?  $\hspace{5mm}$ (ii). no two consecutive letters are the same?  A:(i). 1314. ${\hspace{5mm}}$ (ii). 174.  I thought of using the General Principle of Inclusion and Exclusion along with letting $p_i$ denote a property that.. , and doing so, I will evaluate $E(0)$, which gives us the number of arrangements without any of the properties.   How do I go about doing that? I am trying to use the method stated above in solving this question, but I am unable to generalize the properties $p_i$. Why does the question's closed status disappear when clicking to load a new edit? I'd like to estimate the correlation between:  An ordinal variable: subjects are asked to rate their preference for 6 types of fruit on a 1-5 scale (ranging from very disgusting to very tasty) On average subjects use only 3 points of the scale.  A continuous variable: the same subjects are asked to quickly identify these fruits, which results in an mean accuracy for the 6 fruits.   Is Spearman rho the best method to analyze these data and/or are there other good methods I could consider? Plotting a Continuous signal Atmospheric pressure experiment using a cup with a fluid to hold a glass plate When I was in high school, my teacher did an experiment to show the power of atmospheric pressure.  Experiment: Prepare a glass bottle, fill with water, put a glass plate on the bottle, make sure there is no air in the bottle, just water. Hold the glass bottle and plate, and invert them. Slowly, release the hand which hold the plate. Because the atmospheric pressure, the glass plate will not fall down.    Question 1: As we know, if we didn't put water into the glass bottle, just air in the glass bottle the glass plate will fall down. So, If we use other liquid instead of water, this liquid has smaller density than water, like alcohol, the plate will not fall down. But, if we continue to chose the smaller density liquid until the liquid has density like air the plate will fall down. So, if there is a threshold density of liquid make the plate between falling  down and not falling down?  Question 2: If we put the bottle and plate into water slowly, when the plate and part of bottle are in the water but part of the bottle still above the water, will the plate fall down?  Question 3: Continuing question 2, when both bottle and plate are in the water I know the plate will fall down. So, how does the pressure of water and atmosphere change?  Is there a good description of this phenomena?  Why does the trick continue to work with lower density fluids and why does placing the plate in the water cause it to fall? I understand what the Chinese remainder theorem is. However I am not sure how to apply it to my question. Can someone explain please? Why are there $736$ matrices $M\in \mathcal M_2(\mathbb{Z}_{26})$ for which it holds that $M=M^{-1}$? I'm currently trying to introduce myself to cryptography.  I'm reading about the Hill Cipher currently in the book Applied Abstract Algebra. The Hill Cipher uses an invertible matrix $M$ for encryption and the inverse matrix $M^{-1}$ for decryption. The book recommends to use a matrix $M$ for which it holds that $M=M^{-1}$, since we then have the same key for encryption and decryption.  In the book, they use a $2 \times 2$ matrix $M$ over $\mathbb{Z}_{26}$ as example, and state that for there are 736 $2 \times 2$ matrices for which it hold that $M=M^{-1}$.  I'm trying to pick up on as much as possible when reading things, since I find it counter-productive for learning to skip something, when you don't get the theory behind it. Can someone enlighten to me, as to why it is that there are 736 possible $2 \times 2$ $M=M^{-1}$ matrices and how to find them? I originally read this book in the mid- to late '70s.   The premise was a bureaucracy whose job it was to manipulate events in human history by making the smallest possible change that would effect the desired outcome. Not time cops in the sense of going after law breakers.  The intent was to maintain a policy of non-interference as much as possible but when interference was warranted then to make the least possible change and to do so invisibly.  For example, they might take someone's keys off the dresser and put them just out of sight underneath the dresser where they plausibly might have fallen.  The subject would never know of the manipulation but would then be delayed getting out of the house and the ripples grew from there to avert a war or otherwise affect events on a large scale.  After reading that, whenever I would lose something - especially in an improbable way such as dropping a screw at my feet and then finding it on the other side of the room half an hour later - I would take some consolation in the thought that I had just averted some global catastrophe.  I was pretty scatterbrained as a kid (we call that ADHD nowadays) so I experienced this a lot.  Given that I've spent so much time pondering the ideas from the book, I'd love to re-read it. Choice of personal pronoun in single-author papers Which personal pronoun is appropriate in single-author papers - 'I' or 'we'? Could the use of 'I' be considered egotistical? Or will the use of 'we' be considered to be grammatically incorrect? How do you square an ideal? For some of you, this question is going to seem extremely basic.  I think I understand what an ideal is. Such as $\langle 2, 1 + \sqrt{-5} \rangle$, it consists of all numbers in this ring of the form $2a + (1 + \sqrt{-5})b$.  But then what is $\langle 2, 1 + \sqrt{-5} \rangle^2$? My first thought was $\langle 4, -4 + 2 \sqrt{-5} \rangle$, but that seems wrong somehow. I also had something in the back of my mind saying $\langle 2 \rangle$, but I'm not sure about that one either.  Then I thought about trying to figure out $\langle 2, 1 + \sqrt{-5} \rangle \langle 2, 1 + \sqrt{-5} \rangle$ when I realized I don't actually understand how to multiply ideals to begin with.  I'm only using $\langle 2, 1 + \sqrt{-5} \rangle$ as an example (though that does draw in one question identified as similar that looks much more relevant than all the questions identified as "Questions that may already have your answer"). In a principal ideal domain, would it be correct to think that $\langle a \rangle \langle b \rangle = \langle ab \rangle$?  Any help would be much appreciated.