I have the following problem.  I already solved it but I am not happy with my solution.  I hope for a more slick solution and maybe somebody can help with it.  Is there a way to solve this problem with just the stars/bars method?  Compute the number of ways to permute all letters from $D,D,D,O,O,O,G,G,G$ such that no two $D$ are adjacent and no two $G$ are adjacent.  My attempt. For $k=2,3$, let $\Delta_k$ denote the set of permutations s.t. only $k$ of $D$ are adjacent, and let $\Gamma_k$ denote the set of permutations s.t. only $k$ of $G$ are adjacent.  Let $U$ be the set of all permutations without any conditions. Then $$|U|=\frac{(3+3+3)!}{3!3!3!}=1680.$$  We have $$|\Delta_3|=\frac{(1+3+3)!}{1!3!3!}=140$$ (as $\Delta_3$ is the set of permutations of $DDD,O,O,O,G,G,G$), and $$|\Delta_2|+2|\Delta_3|=\frac{(1+1+3+3)!}{1!1!3!3!}=1120$$ since this number counts the permutations of $DD,D,O,O,O,G,G,G$.  Therefore $$|\Delta_2|=1120-2(140)=840.$$  Similarly $|\Gamma_3|=140$ and $|\Gamma_2|=840$. We want to find $|\Delta_i\cap\Gamma_j|$.  Since $\Delta_3\cap\Gamma_3$ is the set of permutations of $DDD,O,O,O,GGG$, $$|\Delta_3\cap\Gamma_3|=\frac{(1+3+1)!}{1!3!1!}=20.$$  Since $|\Delta_2\cap\Gamma_3|+2|\Delta_3\cap\Gamma_3|$ counts the permutations of $DD,D,O,O,O,GGG$, we have $$|\Delta_2\cap\Gamma_3|+2|\Delta_3\cap\Gamma_3|=\frac{(1+1+3+1)!}{1!1!3!1!}=120$$ so $$|\Delta_2\cap\Gamma_3|=120-2(20)=80.$$  Similarly $|\Delta_3\cap\Gamma_2|=80$. We now want to find $|\Delta_2\cap\Gamma_2|$.  Since $|\Delta_2\cap\Gamma_2|+2|\Delta_3\cap\Gamma_2|+2|\Delta_2\cap\Gamma_3|+4|\Delta_2\cap\Gamma_3|$ counts the number of permutations of $DD,D,O,O,O,GG,G$, we get $$|\Delta_2\cap\Gamma_2|+2|\Delta_3\cap\Gamma_2|+2|\Delta_2\cap\Gamma_3|+4|\Delta_2\cap\Gamma_3|=\frac{(1+1+3+1+1)!}{1!1!3!1!1!}=840.$$  Hence $$|\Delta_2\cap\Gamma_2|=840-2(80)-2(80)-4(20)=440.$$ By inclusion-exclusion principle we have $$|\Delta_2\cup\Delta_3\cup\Gamma_2\cup\Gamma_3|=\sum_{k=2}^3|\Delta_k|+\sum_{k=2}^3|\Gamma_k|-\sum_{i=2}^3\sum_{j=2}^3|\Delta_i\cap \Gamma_j|.$$  Therefore $$|\Delta_2\cup\Delta_3\cup\Gamma_2\cup\Gamma_3|=2(840)+2(140)-(440+80+80+20)=1340.$$  The question asks for the size of $U\setminus(\Delta_2\cup\Delta_3\cup\Gamma_2\cup\Gamma_3)$, which is $$|U|-|\Delta_2\cup\Delta_3\cup\Gamma_2\cup\Gamma_3|=1680-1340=340.$$
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$.
Toggle wireframe mode with hotkey Tool to create text files from a template I have to regularly create 100+ text files from templates. I currently use an overly complicated shell script. I think there is a smarter way to handle this, but I don't know how.  I have a "database" :  # outputfile      template            data1   data2    data3 first.txt         $template_main      $text1  abcd     1234 second.txt        $template_main      $text2  efgh     5678 third.txt         $template_other     $text1  ij       90   And a configuration file :  template_main=main.txt template_other=other.txt text1=whatever text2=blah   The templates are text files with placeholders like %%data2%% (the placeholder form can be changed).  Does someone know a tool to automate this better than with a complicated shell script ? I listened to this on audiobook and it was great.  The premise was a human ends up travelling to an alien planet. The aliens have a perimeter to their 'base' that is under constant attack from the planet's animals. It is revealed towards the end that there is some sort of signal being transmitted that is making all the animals and plant life attack a certain point on the planet (where the aliens are).   Other major plot points I remember: The human traveller falls in love with an alien. The aliens have a sort of virtual training environment that simulates life outside the perimeter, where plants attack you etc. There is a secondary alien group that the human ends up with, and although they are rivals to other group, they have a trade set up.   Any help much appreciated! Thanks. One form of Jensen's inequality is     If $X$ is a random variable and $g$ is a convex function, then   $\mathbb{E}(g(X))\geq g(\mathbb{E}(X))$.   Just out of curiosity, when do we have equality? If and only if $g$ is constant? I mostly use Java and generics are relatively new. I keep reading that Java made the wrong decision or that .NET has better implementations etc. etc.  So, what are the main differences between C++, C#, Java in generics? Pros/cons of each? Is it possible to colour or put textures on Bevel curves? So with my model, I've been struggling to create hair because it always looked weird or off and recently I discovered the "Bevel Curve" addon and it's an absolute lifesaver.   So I converted the bevels into mesh to colour it, except it lags blender like crazy and I need this model for a video game I'm currently developing called Candles(so I can't upload the model, sorry) but I was wondering, is it possible to put a texture on a bevel curve like you would mesh or any other method or giving it colour? I read this book once when I was in middle school. A girl solves a murder or a mystery on a spaceship. It was a thin paperback books.   All I can remember is that there was an alien, and there was a movie star or actress or famous makeup artist on the ship traveling with another woman. By the end of the book the murderer was the woman the actress was traveling with who forced her to use her makeup skills to disguise her, and she was really some kind of alien. Why is $x^0 = 1$ except when $x = 0$? Java Strings: "String s = new String("silly");" Command line move file with long directory path without repeating directory path Is there any way of executing a mv command without typing the full path in the second argument?  Example:  mv my/file/that/has/a/really/long/path/foo.bar some_magic_operator_that_means_the_same_directory/foo.baz Prove that $\lambda = 0$ is an eigenvalue if and only if A is singular. Repeating an equation including its content and number I would like to re-use equations with the same content and number. I know that the thmtools package has a restatable environment to do this for environments (like in ), but I would also like to do this with a single equation that is only part of some environment.  I had a look at the following questions which only aim at repeating the equation number but typing the whole equation twice (the first three) or repeat the content of the equation without a number (the last one):         Based on the answers provided there and on the  I tried to create a macro \restatableeq for restable equations like this:  \documentclass{article}  \usepackage{amsmath}  \newcommand{\restatableeq}[3]{\label{#3}#2\xdef#1{\unexpanded#2\unexpanded\tag{\unexpanded\ref{#3}}}}  \begin{document}  \begin{eqnarray} \restatableeq{\eqone}{This &amp; is &amp; eqation 1}{eq1}\\ Another &amp; simple &amp; equation \end{eqnarray}  \begin{eqnarray} One &amp; more &amp; equation\\ \restatableeq{\eqtwo}{This &amp; is &amp; eqation 2}{eq2} \end{eqnarray}  Here, we use (\ref{eq1}) and (\ref{eq2}) again: \begin{eqnarray*} \eqone\\ \eqtwo \end{eqnarray*}  \end{document}   Unfortunately, it does not work and yields:  ! Missing { inserted. &lt;to be read again&gt;                    T l.10 ...ableeq{\eqone}{This &amp; is &amp; eqation 1}{eq1}                                                   \\ ?   My guess is that the &amp; symbols are not treated as intended but I may well be wrong there.  How can I define a command like \restatableeq that allows me to re-use equations with the same content and number in a setting like in this example (and give it a label such that I can still use \ref as usual in addition to that)? How to automatically start programs in specific workspaces on start up Why do we need to fork to create new processes? Biblatex citation order Question  The test scores of three groups of people are saved as separate vectors in R.  set.seed(1) group1 &lt;- rnorm(100, mean = 75, sd = 10) group2 &lt;- rnorm(100, mean = 85, sd = 10) group3 &lt;- rnorm(100, mean = 95, sd = 10)   I want to know if there is a significant difference in the medians between these groups. I know that I could test group 1 versus group 2 using the Wilcoxon test, like so.  wilcox.test(group1, group2)   However, this compares only two groups at a time, and I would like to compare all three simultaneously. I would like a statistical test that yields a p value at the 0.05 significance level. Could someone please help?  Edit #1 - Mood's median test  Following user Hibernating's suggested answer, I tried Mood's median test.  median.test &lt;- function(x, y){     z &lt;- c(x, y)     g &lt;- rep(1:2, c(length(x), length(y)))     m &lt;- median(z)     fisher.test(z &lt; m, g)$p.value }  median.test(group1, group2)   However, this approach allows me to test for a significant difference between the medians of only two groups at a time. I am not sure of how to use it to compare the medians of all three simultaneously.  Edit #2 - Kruskal-Wallis test  User dmartin's suggested answer appears to be more or less what I need, and allows me to test all three groups simultaneously.  kruskal.test(list(group1, group2, group3))   Edit #3  User Greg Snow helpfully notes in his answer that the Kruskal-Wallis test is appropriate as long as it makes strict assumptions that make it also a test of means. Pagination not working with custom loop I've got a custom loop that I'm using to display some Real Estate listings that will be available within 60 days. I'm calling it with the following function:   &lt;?php  $sixtydays = date('Y/m/d', strtotime('+60 days')); $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $query = new PostsOrderedByMetaQuery(array(   'post_type' =&gt; array('post', 'real-estate'),   'meta_key' =&gt; 'Time Available',   'meta_compare' =&gt; '&lt;=',   'meta_value' =&gt; $sixtydays,   'paged' =&gt; $paged,   'orderby_meta_key' =&gt; 'Price',   'orderby_order'    =&gt; 'ASC' )); ?&gt; &lt;?php while ($query-&gt;have_posts()) : $query-&gt;the_post(); ?&gt;   While the loop works great, I can't get it to paginate. It shows the first 10 (my default) posts but doesn't show the pagination. The only way to display all posts is to show them on one page by adding 'posts_per_page' =&gt; -1, I have similar loops on other pages that have no problem paginating. The only difference with this one is that there are two meta keys that are filtering the posts.   I'm using WP Page Navi for this and the rest of my pages. I'm closing the loop and adding the pagination using the following code:   &lt;?php endwhile; // End the loop. Whew. ?&gt; &lt;?php wp_pagenavi(); ?&gt; &lt;?php wp_reset_query(); ?&gt;   How can I go about fixing this? I wrote a regular expression which works well in a certain program (grep, sed, awk, perl, python, ruby, ksh, bash, zsh, find, emacs, vi, vim, gedit, …). But when I use it in a different program (or on a different unix variant), it stops matching. Why? Prove that, for $p > 3$, $(\frac 3p) = 1$ when $p \equiv 1,11 \pmod{12}$ and $(\frac 3p) = -1$ when $p \equiv 5,7 \pmod{12}$ $(\frac 3p)$ is the Legendre symbol here, not a fraction, if that wasn't clear.  This is what I have so far:  We know by Gauss's Lemma that $(\frac qp) = (-1)^v$ where $$v = \#\left\{1 \le a \le \frac{p-1}{2} \mid aq \equiv k_a \pmod{12}),\space -p/2 &lt; k_a &lt; 0\right\}$$  And we also know that multiples of $(\dfrac{p-1}{2}) \times 3$ must be between $0$ and $p/2$, between $p/2$ and $p$, or between $p$ and $3p/2$.   Representing $p$ as $12k + r$ seems like the next step, but I'm not sure where to go from there. Clicking on a notification on Android app opens an empty feed When I receive a message on an SE post, I get a notification like this:    If I double tap this notification, the SE application opens, but my feed is empty approximately half the time. It looks like this:    If I refresh the feed (slide from the top), the feed does refresh and shows the new notification.   The notification, above, leads to  comment.  I haven't figured out the pattern yet, but this occurs roughly half the time I open a notification. It's occurred for chat messages, comments and answers - but not consistently. I have received notifications for the same post (for example, the two comments after the one linked above) that do not show an empty feed. But, a chat message barely 10 minutes later will show the empty feed again.  I am utilizing the beta app - version 1.0.72 on Android 5.0.1.