Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
GoikLectures
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Goik Martin
GoikLectures
Commits
b768cfc3
Commit
b768cfc3
authored
7 years ago
by
Goik Martin
Browse files
Options
Downloads
Patches
Plain Diff
RPN hint
parent
37fd1d0c
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Doc/Sd1/Ref/Projects/rpnCalculator.webm
+0
-0
0 additions, 0 deletions
Doc/Sd1/Ref/Projects/rpnCalculator.webm
Doc/Sd1/appendix.xml
+27
-16
27 additions, 16 deletions
Doc/Sd1/appendix.xml
with
27 additions
and
16 deletions
Doc/Sd1/Ref/Projects/rpnCalculator.webm
0 → 100644
+
0
−
0
View file @
b768cfc3
File added
This diff is collapsed.
Click to expand it.
Doc/Sd1/appendix.xml
+
27
−
16
View file @
b768cfc3
...
...
@@ -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.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment