Commit 97c77cc3 authored by Dr. Martin Goik's avatar Dr. Martin Goik

Cosmetics

parent 2f56ab23
......@@ -5625,14 +5625,14 @@ try (final Scanner scan = new Scanner(System.in)) {
<m:mo>)</m:mo>
</m:mrow>
</m:math>
</inlineequation> which could be ruled out beforehand
easily rather then creating and filtering them. Do we really
need three nested loops?</para>
</inlineequation> which could be easily ruled out
beforehand rather then creating and filtering them. Do we
really need three nested loops?</para>
<para>Also triples having identical values but in a
different order like <code>(40, 399, 401)</code> and
<code>(40, 401, 399)</code> are equivalent. For this reason
we may consider only triples being ordered by size.</para>
<para>Also triples having identical values in different
order like <code>(40, 399, 401)</code> and <code>(40, 401,
399)</code> are equivalent. For this reason we may consider
only triples being ordered by value.</para>
<para>So the problem can be stated to find the set of all
triples <inlineequation>
......@@ -5862,7 +5862,8 @@ for (int a = 1; a &lt;= sum / 3; a++) {
}
}</programlisting>
<para>This leaves us with eight triples:</para>
<para>We've reduced the original code from three to just two
nested loops. Running this code reveals eight triples:</para>
<screen>(40, 399, 401)
(56, 390, 394)
......@@ -5874,10 +5875,10 @@ for (int a = 1; a &lt;= sum / 3; a++) {
(240, 252, 348)</screen>
<para>The above code can be simplified even further. We
introduce the variable s being shorthand for <code
language="java">sum</code> in our <xref linkend="glo_Java"/>
code. The inner <code language="java">for</code> loop so far
starts with a value of <inlineequation>
introduce a variable s being shorthand for <code
language="java">sum</code>. The <quote>inner</quote> <code
language="java">for</code> loop so far starts with a value of
<inlineequation>
<m:math display="inline">
<m:mrow>
<m:mi>b</m:mi>
......@@ -5914,9 +5915,9 @@ for (int a = 1; a &lt;= sum / 3; a++) {
language="java">c</code> will be decremented by the same
amount.</para>
<para>Regarding the n-th step of the inner <code
language="java">for</code> loop we thus look for a value of n
so that the following equation becomes true:</para>
<para>Regarding the n-th step of the inner loop we thus look
for a value of n so that the following equation becomes
true:</para>
<informalequation>
<m:math display="inline">
......@@ -6089,8 +6090,8 @@ for (int a = 1; a &lt;= sum / 3; a++) {
<para>So for each given value of a there is either no or
exactly one possible solution (since <code
language="java">n</code> is of integer type). Our
<quote>inner</quote> nested loop becomes obsolete.</para>
language="java">n</code> is of integer type). This way the
<quote>inner</quote> loop becomes obsolete.</para>
<para>The above equation must hold for integer arithmetic
leaving no fractional remainder. We introduce two variables
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment