How do I efficiently count the zero padded six digit numbers where the first three digits equal the last three?  My solution is like this. But this is not efficient solution. I have to find best way  public class TicketNumber {    public static void main(String[] args) {     int i1, i2, i3, i4, i5, i6, count = 0;     String str="";     for (i1 = 0; i1 &lt;= 9; i1++) {        for (i2 = 0; i2 &lt;= 9; i2++) {           for (i3 = 0; i3 &lt;= 9; i3++) {              for (i4 = 0; i4 &lt;= 9; i4++) {                 for (i5 = 0; i5 &lt;= 9; i5++) {                    for (i6 = 0; i6 &lt;= 9; i6++) {                       if ((i1+i2+i3) == (i4+i5+i6)) {                          count++;                       }                   }                }             }          }       }    }    System.out.println(count);   } }   I should print all numbers between 000000-999999 which compatible with i1+i2+i3 = i4+i5+i6 condition
How do you left pad an int with zeros when converting to a String in java?  I'm basically looking to pad out integers up to 9999 with leading zeros (e.g. 1 = 0001).
How does Java's PreparedStatement work? I am planning to replace repeatedly executed Statement objects with PreparedStatement objects to improve performance. I am using arguments like the MySQL function now(), and string variables.   Most of the PreparedStatement queries I have seen contained constant values (like 10, and strings like "New York") as arguments used for the ? in the queries. How would I go about using functions like now(), and variables as arguments? Is it necessary to use the ?s in the queries instead of actual values? I am quite confounded. The text for  says:     {1}{G}, {T} : Target creature you control fights another target creature. (Each deals damage equal to its power to the other.)   Does this have anything to do with combat? Or is it just direct damage between two creatures? For example, can one of the creatures have defender? Or what if one of them is tapped?   I've been assuming it is more like the damage dealt by a .  Also: are the two creatures then “tapped” until their next untap step? ie: could you use Ulenvald Tracker to make two creatures fight in your pre-combat step, then enter the combat phase with a creature who just “fought” untapped? Could you make two creatures fight who are both tapped? Cheat-proof online die roller? I am looking for an online die roller that works similarly to the following:   The GM provides a string identifier to the player. E.g., "gandalf attacks balrog #12"   The player enters the id on the roller site, which checks it for uniqueness vs the DB, then generates the results, lined to that id.   The GM can check the results by id.     An alternative implementation would be for the GM to request a range of pre-generated ids from the site and hand them out to the players for rolls. E.g., "please roll 5d8 with id #314159265"  Is there anything similar?  Notes and Clarifications:  As Thales Sarczuk inferred, this is indeed for "play by forum/email" games.  The idea is to have "verifiable" rolls, preventing "roll until you you get a good result" scenarios. However, it will be used on forums that are not gaming-specific so using plugins is not an option.  Thank you! How to only substitute lines that match several patterns in sed? $ echo -e 'CH12\nCH23au' | sed '/^CH/s=^=&lt;b&gt;=' &lt;b&gt;CH12 &lt;b&gt;CH23au   I know I can match lines starting with CH by ^CH but how can I match multiple patterns?   Example:  Input:  CH12 CH23au   Output:  CH12 &lt;b&gt;CH23au   How to only put &lt;b&gt; where there is ^CH and au in the line? Is there an idiom that means "revealing a secret unintentionally"? I am thinking there could be an idiom that states that you or someone revealed a secret unintentionally? Can you think of an idiom like that? I am looking for an idiom I can use to write a blog post about the recent incident where Secretary Pompeo unintentionally revealed the dirty secrets behind the CIA. Suppose we want to prove $$ k \binom{n}{k} = n \binom{n-1}{k-1}$$   In the LHS we are choosing a team of $k$ players from $n$ players. Then we are choosing a captain. In the RHS we are choosing a captain from the $n$ players. Then we are choosing the remaining $k-1$ players from the $n-1$ players.   Is this a correct interpretation? How would you do a "not in" query with LINQ? I have two collections which have property Email in both collections. I need to get a list of the items in the first list where Email does not exist in the second list. With SQL I would just use "not in", but I do not know the equivalent in LINQ. How is that done?  So far I have a join, like...  var matches = from item1 in list1 join item2 in list2 on item1.Email equals item2.Email select new { Email = list1.Email };   But I cannot join since I need the difference and the join would fail. I need some way of using Contains or Exists I believe. I just have not found an example to do that yet. Showing arrowheads in line end using QGIS? Cannot authenticate without a password My university's thesis guidelines require that each bibliographic entry appear in whole on a single page, rather than being split across two. How can I prevent (La)TeX breaking a paragraph across a page boundary? There is no continuous injective function $f:\mathbb{R}^n\longrightarrow\mathbb{R}^m$ The stress tensor can be written as: $$\sigma_{ij}=-p \delta_{ij}+\sigma'_{ij}\label{1}\tag{1}$$ where $\sigma_{ij}'$ is called the extra stress tensor.   From what I understand pressure is pressure is force per unit area, so that the force acting on the surface $d\vec A$ is given by:  $$\vec F=-p d\vec A\label{2}\tag{2}$$ (This has the effect that the force on an infinitesimally thin surface due to a continuous pressure is zero). However, $\sigma_{ij}$ represent the force in the $i$ direction on a surface with normal in the $\hat e_j$ direction. So the force acting on a surface $d \vec A$ must be: $$F_i=\sigma_{ij}dA_j\label{3}\tag{3}$$ Equations (2) and (3) clearly do not agree (even if we look soley at the force in the $d\vec A$ direction they don't agree). So my question is what is the exact meaning of pressure in expression (1) and why do we not have: $$\sigma_{ii}=-p$$ Need to understand why my Schengen visa was refused Computing matrices of linear transformation under different basis Came across a problem in my textbook and I am having trouble with it, the book provides an answer but no workings. Looking to get an explanation of what is going on  help I prepare for an exam. If we let $T : \mathbb R^2 \to \mathbb R^2$ be a linear transformation. Consdider two bases $V$ and $W$ of the vector space $\mathbb R^2$, where $V=\{v_1,v_2\}$ with $ v_1 =  \begin{bmatrix} -2 \\1   \end{bmatrix}$ and  $ v_2 =  \begin{bmatrix} 1 \\1   \end{bmatrix}$ and where $W = \{w_1,w_2\}$ with  $ w_1 =  \begin{bmatrix} -1 \\4   \end{bmatrix}$ and  $ w_2 =  \begin{bmatrix} 0 \\1   \end{bmatrix}$. Suppose that  $ A =  \begin{bmatrix} 1&amp;2   \\-1 &amp;4    \end{bmatrix}$ is the matrix of $T$ under basis $W$. I need to find the matrix $B$ the matrix of $T$ under basis $V$.  The solution is:   $ B = P^{-1}AP$ = $   \begin{bmatrix} -30&amp;22   \\-48 &amp; 35    \end{bmatrix} $  But I don't know why. For $D$ a GCD domain , let $a,b,x \in D \setminus \{0\}$ , then is it true that $\gcd (ax,bx)=x \cdot \gcd (a,b)$? Package Listings Warning: Text dropped after begin of listing when calling function I'm trying to this:  \newcommand{\code}[1] {\begin{lstlisting} {#1} \end{lstlisting} }   But I keep getting this error:  Package Listings Warning: Text dropped after begin of listing   I'm calling \usepackage and all so, do any of you knows how to solve this? Forward vs Forwards How to open a new Terminal with shell prompt and running multiple commands in Command Line? I want to Open a new Terminal in from within terminal.  It should have Shell prompt as well as already run few commands.  How to do it ? Reference book on measure theory I post this question with some personal specifications. I hope it does not overlap with old posted questions.  Recently I strongly feel that I have to review the knowledge of measure theory for the sake of starting my thesis.  I am not totally new with measure theory, since I have taken and past one course at the graduate level. Unfortunately, because the lecturer was not so good at teaching, I followed the course by self-study. Now I feel that all the knowledge has gone after the exam and still don’t have a clear overview on the structure of measure theory. And here come my specified requirements for a reference book.   I wish the book elaborates the proofs, since I will read it on my own again, sadly. And this is the most important criterion for the book. I wish the book covers most of the topics in measure theory. Although the topic of my thesis is on stochastic integration, I do want to review measure theory at a more general level, which means it could emphasize on both aspects of analysis and probability. If such a condition cannot be achieved, I'd like to more focus on probability. I wish the book could deal with convergences and uniform integrability carefully, as Chung’s probability book.    My expectation is after thorough reading, I could have strong background to start a thesis on stochastic integration at an analytic level.  Sorry for such a tedious question.  P.S: the textbook I used is Schilling’s book: measures, integrals and martingales. It is a pretty good textbook, but misprints really ruin the fun of reading. Pie Chart without labels in beamer using pgf-pie EDIT The accepted answer completely solves my immediate problem, but for more detailed analysis of the underlying issue please refer to answer by cfr. Basically, pstricks and pdfTex don't mix well.  I have a beamer presentation with a lot of pie charts. I use pgf-pie package because it is easy and (mostly) does what I need. I have one particular pie-chart that should have no labels at all. I have tried adding  /tikz/nodes={text opacity=0,overlay}   to the code following advice found here.    \documentclass{standalone} \usepackage{pgf-pie} \begin{document}  \begin{tikzpicture} \pie [explode=0.1, color={blue!70, green!80, red, yellow} ,/tikz /nodes={text opacity=0,overlay}]{10/, 20/, 30/, 40/} \end{tikzpicture} \end{document}   Now, the strange thing is, the code works well in the example above (standalone class). However, it doesn't seem to do anything inside a beamer presentation, i.e. the labels still show. It seems that there is some sort of package conflict. How could I enable this to work in the beamer presentation? I know there are other ways to produce this but pgf-pie is quite handy otherwise.  \documentclass[12pt,compress]{beamer} \usetheme{Warsaw}  \setbeamertemplate{navigation symbols}{}%remove navigation symbols \setbeamercolor{alerted text}{fg=magenta}  %\usepackage[latin1]{inputenc} \usepackage[T1]{fontenc} \usepackage{wasysym} \usepackage{multicol} \usepackage{amsmath} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{graphicx} \usepackage{xcolor} %\usepackage{iwona} \usepackage{wrapfig} \input{FactorTree} \usepackage{pstricks} \usetikzlibrary{matrix} \usepackage{tkz-euclide} \usetkzobj[all] \usepackage{xlop} \usepackage{tcolorbox} \usepackage{pgfplots} \usepackage{pgf-pie} \usepackage[makeroom]{cancel} \input{longdiv}