Skip to content
Snippets Groups Projects
Commit b768cfc3 authored by Goik Martin's avatar Goik Martin
Browse files

RPN hint

parent 37fd1d0c
No related branches found
No related tags found
No related merge requests found
File added
......@@ -668,15 +668,23 @@ public void test_400() {
</listitem>
</orderedlist>
<para>A prototype is available at <link
xlink:href="/Sd1/Ref/Src/rpncalculator-0.1.jar">rpncalculator-0.1.jar</link>.
Executing <command>java</command> <option>-jar</option>
<option>rpncalculator-0.1.jar</option> allows for evaluating <abbrev
xlink:href="https://en.wikipedia.org/wiki/Reverse_Polish_notation">RPN</abbrev>
expressions in a terminal:</para>
<mediaobject>
<videoobject>
<videodata fileref="Ref/Projects/rpnCalculator.webm"
format="video/webm"/>
</videoobject>
</mediaobject>
<section xml:id="sd1_sect_projectRpnCalculatorFunctionality">
<title>Desired functionality</title>
<para>An prototype is available at <link
xlink:href="/Sd1/Ref/Src/rpncalculator-0.1.jar">rpncalculator-0.1.jar</link>.
Execution using <command>java</command> <option>-jar</option>
<option>rpncalculator-0.1.jar</option> allows for playing with
expressions in a terminal based style.</para>
<para>Implement the following elements:</para>
<glosslist>
......@@ -1454,12 +1462,14 @@ public class AppTest {
<itemizedlist>
<listitem>
<para>Generating all prime numbers of type <code language="java">int</code>.</para>
<para>Generating all prime numbers of type <code
language="java">int</code>.</para>
</listitem>
<listitem>
<para>Using this set of prime numbers for decomposing arbitrary
<code language="java">int</code> values into prime factors e.g.:</para>
<code language="java">int</code> values into prime factors
e.g.:</para>
<para>1050 = 2 * 3 * 5 * 5 * 7</para>
</listitem>
......@@ -1472,8 +1482,8 @@ public class AppTest {
<programlisting language="java">boolean[] nonPrimes = new boolean[100];</programlisting>
<para>This array will initially be filled with 100 <code language="java">false</code>
values. The idea is using the <link
<para>This array will initially be filled with 100 <code
language="java">false</code> values. The idea is using the <link
xlink:href="https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes#Euler.27s_Sieve">Euler
sieve algorithm</link> to turn all non-prime value to <code>true
(t)</code> and leaving al prime index values at <code>false
......@@ -1532,8 +1542,8 @@ value | t| f| f| f| t| f| f| t| ...</screen>
<para>Decompose the <link
xlink:href="https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes#Euler.27s_Sieve">Euler
sieve algorithm</link> into smaller tasks and write appropriate tests.
Start with small <code language="java">limit</code> values (like 20) and extend to
<code
Start with small <code language="java">limit</code> values (like 20)
and extend to <code
xlink:href="https://docs.oracle.com/javase/9/docs/api/java/lang/Integer.html#MAX_VALUE">Integer.MAX_VALUE</code>
step by step.</para>
</tip>
......@@ -1597,8 +1607,8 @@ public class PrimeFrequency {
}</programlisting>
<para>Now 2 * 3 * 5 * 5 * 7 may be represented by three (not four!)
instances of <code language="java">PrimeFrequency</code>. In order to represent the
whole product implement a second container:</para>
instances of <code language="java">PrimeFrequency</code>. In order to
represent the whole product implement a second container:</para>
<programlisting language="java">/**
* Representing integer values by an ordered set of prime factors among with
......@@ -1671,8 +1681,9 @@ public class PrimeFrequencySet {
}
}</programlisting>
<para>This allows for decomposing arbitrary <code language="java">int</code> values into
their prime factors. We show a unit test example:</para>
<para>This allows for decomposing arbitrary <code
language="java">int</code> values into their prime factors. We show a
unit test example:</para>
<programlisting language="java">/**
* Prime factor decomposition.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment