Merge remote-tracking branch 'eugenp/master'
This commit is contained in:
commit
dd07d83133
|
@ -63,4 +63,6 @@ jmeter/src/main/resources/*-JMeter.csv
|
||||||
**/tmp
|
**/tmp
|
||||||
**/out-tsc
|
**/out-tsc
|
||||||
**/nbproject/
|
**/nbproject/
|
||||||
**/nb-configuration.xml
|
**/nb-configuration.xml
|
||||||
|
core-scala/.cache-main
|
||||||
|
core-scala/.cache-tests
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/target/
|
/target/
|
||||||
.settings/
|
.settings/
|
||||||
.classpath
|
.classpath
|
||||||
.project
|
.project
|
|
@ -0,0 +1,4 @@
|
||||||
|
## Relevant articles:
|
||||||
|
|
||||||
|
- [Introduction to Jenetics Library](http://www.baeldung.com/jenetics)
|
||||||
|
- [Ant Colony Optimization](http://www.baeldung.com/java-ant-colony-optimization)
|
|
@ -0,0 +1,64 @@
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>com.baeldung</groupId>
|
||||||
|
<artifactId>algorithms-genetic</artifactId>
|
||||||
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>com.baeldung</groupId>
|
||||||
|
<artifactId>parent-modules</artifactId>
|
||||||
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.commons</groupId>
|
||||||
|
<artifactId>commons-math3</artifactId>
|
||||||
|
<version>${commons-math3.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-codec</groupId>
|
||||||
|
<artifactId>commons-codec</artifactId>
|
||||||
|
<version>${commons-codec.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<version>${lombok.version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.jenetics</groupId>
|
||||||
|
<artifactId>jenetics</artifactId>
|
||||||
|
<version>${io.jenetics.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.assertj</groupId>
|
||||||
|
<artifactId>assertj-core</artifactId>
|
||||||
|
<version>${org.assertj.core.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<pluginManagement>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
|
<artifactId>exec-maven-plugin</artifactId>
|
||||||
|
<version>${exec-maven-plugin.version}</version>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</pluginManagement>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<lombok.version>1.16.12</lombok.version>
|
||||||
|
<commons-math3.version>3.6.1</commons-math3.version>
|
||||||
|
<io.jenetics.version>3.7.0</io.jenetics.version>
|
||||||
|
<org.assertj.core.version>3.9.0</org.assertj.core.version>
|
||||||
|
<commons-codec.version>1.11</commons-codec.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
</project>
|
|
@ -1,20 +1,20 @@
|
||||||
package com.java.src;
|
package com.java.src;
|
||||||
|
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
|
|
||||||
public class RoundUpToHundred {
|
public class RoundUpToHundred {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
Scanner scanner = new Scanner(System.in);
|
Scanner scanner = new Scanner(System.in);
|
||||||
double input = scanner.nextDouble();
|
double input = scanner.nextDouble();
|
||||||
scanner.close();
|
scanner.close();
|
||||||
|
|
||||||
RoundUpToHundred.round(input);
|
RoundUpToHundred.round(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
static long round(double input) {
|
static long round(double input) {
|
||||||
long i = (long) Math.ceil(input);
|
long i = (long) Math.ceil(input);
|
||||||
return ((i + 99) / 100) * 100;
|
return ((i + 99) / 100) * 100;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,14 +1,14 @@
|
||||||
package com.java.src;
|
package com.java.src;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class RoundUpToHundredTest {
|
public class RoundUpToHundredTest {
|
||||||
@Test
|
@Test
|
||||||
public void givenInput_whenRound_thenRoundUpToTheNearestHundred() {
|
public void givenInput_whenRound_thenRoundUpToTheNearestHundred() {
|
||||||
assertEquals("Rounded up to hundred", 100, RoundUpToHundred.round(99));
|
assertEquals("Rounded up to hundred", 100, RoundUpToHundred.round(99));
|
||||||
assertEquals("Rounded up to three hundred ", 300, RoundUpToHundred.round(200.2));
|
assertEquals("Rounded up to three hundred ", 300, RoundUpToHundred.round(200.2));
|
||||||
assertEquals("Returns same rounded value", 400, RoundUpToHundred.round(400));
|
assertEquals("Returns same rounded value", 400, RoundUpToHundred.round(400));
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
/target/
|
||||||
|
.settings/
|
||||||
|
.classpath
|
||||||
|
.project
|
|
@ -0,0 +1,12 @@
|
||||||
|
## Relevant articles:
|
||||||
|
|
||||||
|
- [Validating Input With Finite Automata in Java](http://www.baeldung.com/java-finite-automata)
|
||||||
|
- [Example of Hill Climbing Algorithm](http://www.baeldung.com/java-hill-climbing-algorithm)
|
||||||
|
- [Monte Carlo Tree Search for Tic-Tac-Toe Game](http://www.baeldung.com/java-monte-carlo-tree-search)
|
||||||
|
- [Binary Search Algorithm in Java](http://www.baeldung.com/java-binary-search)
|
||||||
|
- [Introduction to Minimax Algorithm](http://www.baeldung.com/java-minimax-algorithm)
|
||||||
|
- [How to Calculate Levenshtein Distance in Java?](http://www.baeldung.com/java-levenshtein-distance)
|
||||||
|
- [How to Find the Kth Largest Element in Java](http://www.baeldung.com/java-kth-largest-element)
|
||||||
|
- [Multi-Swarm Optimization Algorithm in Java](http://www.baeldung.com/java-multi-swarm-algorithm)
|
||||||
|
- [String Search Algorithms for Large Texts](http://www.baeldung.com/java-full-text-search-algorithms)
|
||||||
|
- [Check If a String Contains All The Letters of The Alphabet](https://www.baeldung.com/java-string-contains-all-letters)
|
|
@ -0,0 +1,78 @@
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>com.baeldung</groupId>
|
||||||
|
<artifactId>algorithms-miscellaneous-1</artifactId>
|
||||||
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>com.baeldung</groupId>
|
||||||
|
<artifactId>parent-modules</artifactId>
|
||||||
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.commons</groupId>
|
||||||
|
<artifactId>commons-math3</artifactId>
|
||||||
|
<version>${commons-math3.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-codec</groupId>
|
||||||
|
<artifactId>commons-codec</artifactId>
|
||||||
|
<version>${commons-codec.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<version>${lombok.version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.assertj</groupId>
|
||||||
|
<artifactId>assertj-core</artifactId>
|
||||||
|
<version>${org.assertj.core.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<pluginManagement>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
|
<artifactId>exec-maven-plugin</artifactId>
|
||||||
|
<version>${exec-maven-plugin.version}</version>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</pluginManagement>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
<reporting>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
|
<artifactId>cobertura-maven-plugin</artifactId>
|
||||||
|
<version>2.7</version>
|
||||||
|
<configuration>
|
||||||
|
<instrumentation>
|
||||||
|
<ignores>
|
||||||
|
<ignore>com/baeldung/algorithms/dijkstra/*</ignore>
|
||||||
|
</ignores>
|
||||||
|
<excludes>
|
||||||
|
<exclude>com/baeldung/algorithms/dijkstra/*</exclude>
|
||||||
|
</excludes>
|
||||||
|
</instrumentation>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</reporting>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<lombok.version>1.16.12</lombok.version>
|
||||||
|
<commons-math3.version>3.6.1</commons-math3.version>
|
||||||
|
<org.assertj.core.version>3.9.0</org.assertj.core.version>
|
||||||
|
<commons-codec.version>1.11</commons-codec.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
</project>
|
|
@ -0,0 +1 @@
|
||||||
|
/bin/
|
|
@ -0,0 +1,20 @@
|
||||||
|
package com.java.src;
|
||||||
|
|
||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
|
public class RoundUpToHundred {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
Scanner scanner = new Scanner(System.in);
|
||||||
|
double input = scanner.nextDouble();
|
||||||
|
scanner.close();
|
||||||
|
|
||||||
|
RoundUpToHundred.round(input);
|
||||||
|
}
|
||||||
|
|
||||||
|
static long round(double input) {
|
||||||
|
long i = (long) Math.ceil(input);
|
||||||
|
return ((i + 99) / 100) * 100;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package com.java.src;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
public class RoundUpToHundredTest {
|
||||||
|
@Test
|
||||||
|
public void givenInput_whenRound_thenRoundUpToTheNearestHundred() {
|
||||||
|
assertEquals("Rounded up to hundred", 100, RoundUpToHundred.round(99));
|
||||||
|
assertEquals("Rounded up to three hundred ", 300, RoundUpToHundred.round(200.2));
|
||||||
|
assertEquals("Returns same rounded value", 400, RoundUpToHundred.round(400));
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,12 +1,12 @@
|
||||||
S ########
|
S ########
|
||||||
# #
|
# #
|
||||||
# ### ## #
|
# ### ## #
|
||||||
# # # #
|
# # # #
|
||||||
# # # # #
|
# # # # #
|
||||||
# ## #####
|
# ## #####
|
||||||
# # #
|
# # #
|
||||||
# # # # #
|
# # # # #
|
||||||
##### ####
|
##### ####
|
||||||
# # E
|
# # E
|
||||||
# # # #
|
# # # #
|
||||||
##########
|
##########
|
|
@ -1,22 +1,22 @@
|
||||||
S ##########################
|
S ##########################
|
||||||
# # # #
|
# # # #
|
||||||
# # #### ############### #
|
# # #### ############### #
|
||||||
# # # # # #
|
# # # # # #
|
||||||
# # #### # # ###############
|
# # #### # # ###############
|
||||||
# # # # # # #
|
# # # # # # #
|
||||||
# # # #### ### ########### #
|
# # # #### ### ########### #
|
||||||
# # # # # #
|
# # # # # #
|
||||||
# ################## #
|
# ################## #
|
||||||
######### # # # # #
|
######### # # # # #
|
||||||
# # #### # ####### # #
|
# # #### # ####### # #
|
||||||
# # ### ### # # # # #
|
# # ### ### # # # # #
|
||||||
# # ## # ##### # #
|
# # ## # ##### # #
|
||||||
##### ####### # # # # #
|
##### ####### # # # # #
|
||||||
# # ## ## #### # #
|
# # ## ## #### # #
|
||||||
# ##### ####### # #
|
# ##### ####### # #
|
||||||
# # ############
|
# # ############
|
||||||
####### ######### # #
|
####### ######### # #
|
||||||
# # ######## #
|
# # ######## #
|
||||||
# ####### ###### ## # E
|
# ####### ###### ## # E
|
||||||
# # # ## #
|
# # # ## #
|
||||||
############################
|
############################
|
|
@ -0,0 +1,4 @@
|
||||||
|
/target/
|
||||||
|
.settings/
|
||||||
|
.classpath
|
||||||
|
.project
|
|
@ -2,20 +2,8 @@
|
||||||
|
|
||||||
- [Dijkstra Algorithm in Java](http://www.baeldung.com/java-dijkstra)
|
- [Dijkstra Algorithm in Java](http://www.baeldung.com/java-dijkstra)
|
||||||
- [Introduction to Cobertura](http://www.baeldung.com/cobertura)
|
- [Introduction to Cobertura](http://www.baeldung.com/cobertura)
|
||||||
- [Ant Colony Optimization](http://www.baeldung.com/java-ant-colony-optimization)
|
|
||||||
- [Validating Input With Finite Automata in Java](http://www.baeldung.com/java-finite-automata)
|
|
||||||
- [Introduction to Jenetics Library](http://www.baeldung.com/jenetics)
|
|
||||||
- [Example of Hill Climbing Algorithm](http://www.baeldung.com/java-hill-climbing-algorithm)
|
|
||||||
- [Monte Carlo Tree Search for Tic-Tac-Toe Game](http://www.baeldung.com/java-monte-carlo-tree-search)
|
|
||||||
- [String Search Algorithms for Large Texts](http://www.baeldung.com/java-full-text-search-algorithms)
|
|
||||||
- [Test a Linked List for Cyclicity](http://www.baeldung.com/java-linked-list-cyclicity)
|
- [Test a Linked List for Cyclicity](http://www.baeldung.com/java-linked-list-cyclicity)
|
||||||
- [Binary Search Algorithm in Java](http://www.baeldung.com/java-binary-search)
|
|
||||||
- [Bubble Sort in Java](http://www.baeldung.com/java-bubble-sort)
|
|
||||||
- [Introduction to JGraphT](http://www.baeldung.com/jgrapht)
|
- [Introduction to JGraphT](http://www.baeldung.com/jgrapht)
|
||||||
- [Introduction to Minimax Algorithm](http://www.baeldung.com/java-minimax-algorithm)
|
|
||||||
- [How to Calculate Levenshtein Distance in Java?](http://www.baeldung.com/java-levenshtein-distance)
|
|
||||||
- [How to Find the Kth Largest Element in Java](http://www.baeldung.com/java-kth-largest-element)
|
|
||||||
- [Multi-Swarm Optimization Algorithm in Java](http://www.baeldung.com/java-multi-swarm-algorithm)
|
|
||||||
- [A Maze Solver in Java](http://www.baeldung.com/java-solve-maze)
|
- [A Maze Solver in Java](http://www.baeldung.com/java-solve-maze)
|
||||||
- [Create a Sudoku Solver in Java](http://www.baeldung.com/java-sudoku)
|
- [Create a Sudoku Solver in Java](http://www.baeldung.com/java-sudoku)
|
||||||
- [Displaying Money Amounts in Words](http://www.baeldung.com/java-money-into-words)
|
- [Displaying Money Amounts in Words](http://www.baeldung.com/java-money-into-words)
|
||||||
|
@ -27,10 +15,6 @@
|
||||||
- [Check If Two Rectangles Overlap In Java](https://www.baeldung.com/java-check-if-two-rectangles-overlap)
|
- [Check If Two Rectangles Overlap In Java](https://www.baeldung.com/java-check-if-two-rectangles-overlap)
|
||||||
- [Calculate the Distance Between Two Points in Java](https://www.baeldung.com/java-distance-between-two-points)
|
- [Calculate the Distance Between Two Points in Java](https://www.baeldung.com/java-distance-between-two-points)
|
||||||
- [Find the Intersection of Two Lines in Java](https://www.baeldung.com/java-intersection-of-two-lines)
|
- [Find the Intersection of Two Lines in Java](https://www.baeldung.com/java-intersection-of-two-lines)
|
||||||
- [Check If a String Contains All The Letters of The Alphabet](https://www.baeldung.com/java-string-contains-all-letters)
|
|
||||||
- [Round Up to the Nearest Hundred](https://www.baeldung.com/java-round-up-nearest-hundred)
|
- [Round Up to the Nearest Hundred](https://www.baeldung.com/java-round-up-nearest-hundred)
|
||||||
- [Merge Sort in Java](https://www.baeldung.com/java-merge-sort)
|
|
||||||
- [Calculate Percentage in Java](https://www.baeldung.com/java-calculate-percentage)
|
- [Calculate Percentage in Java](https://www.baeldung.com/java-calculate-percentage)
|
||||||
- [Quicksort Algorithm Implementation in Java](https://www.baeldung.com/java-quicksort)
|
|
||||||
- [Insertion Sort in Java](https://www.baeldung.com/java-insertion-sort)
|
|
||||||
- [Converting Between Byte Arrays and Hexadecimal Strings in Java](https://www.baeldung.com/java-byte-arrays-hex-strings)
|
- [Converting Between Byte Arrays and Hexadecimal Strings in Java](https://www.baeldung.com/java-byte-arrays-hex-strings)
|
|
@ -1,96 +1,90 @@
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.baeldung</groupId>
|
<groupId>com.baeldung</groupId>
|
||||||
<artifactId>algorithms</artifactId>
|
<artifactId>algorithms-miscellaneous-2</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>com.baeldung</groupId>
|
<groupId>com.baeldung</groupId>
|
||||||
<artifactId>parent-modules</artifactId>
|
<artifactId>parent-modules</artifactId>
|
||||||
<version>1.0.0-SNAPSHOT</version>
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.commons</groupId>
|
<groupId>org.apache.commons</groupId>
|
||||||
<artifactId>commons-math3</artifactId>
|
<artifactId>commons-math3</artifactId>
|
||||||
<version>${commons-math3.version}</version>
|
<version>${commons-math3.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-codec</groupId>
|
<groupId>commons-codec</groupId>
|
||||||
<artifactId>commons-codec</artifactId>
|
<artifactId>commons-codec</artifactId>
|
||||||
<version>${commons-codec.version}</version>
|
<version>${commons-codec.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
<artifactId>lombok</artifactId>
|
<artifactId>lombok</artifactId>
|
||||||
<version>${lombok.version}</version>
|
<version>${lombok.version}</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.jenetics</groupId>
|
<groupId>org.jgrapht</groupId>
|
||||||
<artifactId>jenetics</artifactId>
|
<artifactId>jgrapht-core</artifactId>
|
||||||
<version>${io.jenetics.version}</version>
|
<version>${org.jgrapht.core.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jgrapht</groupId>
|
<groupId>pl.allegro.finance</groupId>
|
||||||
<artifactId>jgrapht-core</artifactId>
|
<artifactId>tradukisto</artifactId>
|
||||||
<version>${org.jgrapht.core.version}</version>
|
<version>${tradukisto.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>pl.allegro.finance</groupId>
|
<groupId>org.assertj</groupId>
|
||||||
<artifactId>tradukisto</artifactId>
|
<artifactId>assertj-core</artifactId>
|
||||||
<version>${tradukisto.version}</version>
|
<version>${org.assertj.core.version}</version>
|
||||||
</dependency>
|
<scope>test</scope>
|
||||||
<dependency>
|
</dependency>
|
||||||
<groupId>org.assertj</groupId>
|
</dependencies>
|
||||||
<artifactId>assertj-core</artifactId>
|
|
||||||
<version>${org.assertj.core.version}</version>
|
<build>
|
||||||
<scope>test</scope>
|
<pluginManagement>
|
||||||
</dependency>
|
<plugins>
|
||||||
</dependencies>
|
<plugin>
|
||||||
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
<build>
|
<artifactId>exec-maven-plugin</artifactId>
|
||||||
<pluginManagement>
|
<version>${exec-maven-plugin.version}</version>
|
||||||
<plugins>
|
</plugin>
|
||||||
<plugin>
|
</plugins>
|
||||||
<groupId>org.codehaus.mojo</groupId>
|
</pluginManagement>
|
||||||
<artifactId>exec-maven-plugin</artifactId>
|
</build>
|
||||||
<version>${exec-maven-plugin.version}</version>
|
|
||||||
</plugin>
|
<reporting>
|
||||||
</plugins>
|
<plugins>
|
||||||
</pluginManagement>
|
<plugin>
|
||||||
</build>
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
|
<artifactId>cobertura-maven-plugin</artifactId>
|
||||||
<reporting>
|
<version>2.7</version>
|
||||||
<plugins>
|
<configuration>
|
||||||
<plugin>
|
<instrumentation>
|
||||||
<groupId>org.codehaus.mojo</groupId>
|
<ignores>
|
||||||
<artifactId>cobertura-maven-plugin</artifactId>
|
<ignore>com/baeldung/algorithms/dijkstra/*</ignore>
|
||||||
<version>2.7</version>
|
</ignores>
|
||||||
<configuration>
|
<excludes>
|
||||||
<instrumentation>
|
<exclude>com/baeldung/algorithms/dijkstra/*</exclude>
|
||||||
<ignores>
|
</excludes>
|
||||||
<ignore>com/baeldung/algorithms/dijkstra/*</ignore>
|
</instrumentation>
|
||||||
</ignores>
|
</configuration>
|
||||||
<excludes>
|
</plugin>
|
||||||
<exclude>com/baeldung/algorithms/dijkstra/*</exclude>
|
</plugins>
|
||||||
</excludes>
|
</reporting>
|
||||||
</instrumentation>
|
|
||||||
</configuration>
|
<properties>
|
||||||
</plugin>
|
<lombok.version>1.16.12</lombok.version>
|
||||||
</plugins>
|
<commons-math3.version>3.6.1</commons-math3.version>
|
||||||
</reporting>
|
<tradukisto.version>1.0.1</tradukisto.version>
|
||||||
|
<org.jgrapht.core.version>1.0.1</org.jgrapht.core.version>
|
||||||
<properties>
|
<org.assertj.core.version>3.9.0</org.assertj.core.version>
|
||||||
<lombok.version>1.16.12</lombok.version>
|
<commons-codec.version>1.11</commons-codec.version>
|
||||||
<commons-math3.version>3.6.1</commons-math3.version>
|
</properties>
|
||||||
<tradukisto.version>1.0.1</tradukisto.version>
|
|
||||||
<io.jenetics.version>3.7.0</io.jenetics.version>
|
|
||||||
<org.jgrapht.core.version>1.0.1</org.jgrapht.core.version>
|
|
||||||
<org.assertj.core.version>3.9.0</org.assertj.core.version>
|
|
||||||
<commons-codec.version>1.11</commons-codec.version>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
</project>
|
</project>
|
|
@ -0,0 +1 @@
|
||||||
|
/bin/
|
|
@ -0,0 +1,20 @@
|
||||||
|
package com.java.src;
|
||||||
|
|
||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
|
public class RoundUpToHundred {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
Scanner scanner = new Scanner(System.in);
|
||||||
|
double input = scanner.nextDouble();
|
||||||
|
scanner.close();
|
||||||
|
|
||||||
|
RoundUpToHundred.round(input);
|
||||||
|
}
|
||||||
|
|
||||||
|
static long round(double input) {
|
||||||
|
long i = (long) Math.ceil(input);
|
||||||
|
return ((i + 99) / 100) * 100;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package com.java.src;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
public class RoundUpToHundredTest {
|
||||||
|
@Test
|
||||||
|
public void givenInput_whenRound_thenRoundUpToTheNearestHundred() {
|
||||||
|
assertEquals("Rounded up to hundred", 100, RoundUpToHundred.round(99));
|
||||||
|
assertEquals("Rounded up to three hundred ", 300, RoundUpToHundred.round(200.2));
|
||||||
|
assertEquals("Returns same rounded value", 400, RoundUpToHundred.round(400));
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,15 +1,15 @@
|
||||||
package com.baeldung.algorithms.editdistance;
|
package com.baeldung.algorithms.editdistance;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
public class EditDistanceBase {
|
public class EditDistanceBase {
|
||||||
|
|
||||||
static int costOfSubstitution(char a, char b) {
|
static int costOfSubstitution(char a, char b) {
|
||||||
return a == b ? 0 : 1;
|
return a == b ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int min(int... numbers) {
|
static int min(int... numbers) {
|
||||||
return Arrays.stream(numbers)
|
return Arrays.stream(numbers)
|
||||||
.min().orElse(Integer.MAX_VALUE);
|
.min().orElse(Integer.MAX_VALUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,26 +1,26 @@
|
||||||
package com.baeldung.algorithms.editdistance;
|
package com.baeldung.algorithms.editdistance;
|
||||||
|
|
||||||
public class EditDistanceDynamicProgramming extends EditDistanceBase {
|
public class EditDistanceDynamicProgramming extends EditDistanceBase {
|
||||||
|
|
||||||
static int calculate(String x, String y) {
|
static int calculate(String x, String y) {
|
||||||
int[][] dp = new int[x.length() + 1][y.length() + 1];
|
int[][] dp = new int[x.length() + 1][y.length() + 1];
|
||||||
|
|
||||||
for (int i = 0; i <= x.length(); i++) {
|
for (int i = 0; i <= x.length(); i++) {
|
||||||
for (int j = 0; j <= y.length(); j++) {
|
for (int j = 0; j <= y.length(); j++) {
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
dp[i][j] = j;
|
dp[i][j] = j;
|
||||||
|
|
||||||
else if (j == 0)
|
else if (j == 0)
|
||||||
dp[i][j] = i;
|
dp[i][j] = i;
|
||||||
|
|
||||||
else {
|
else {
|
||||||
dp[i][j] = min(dp[i - 1][j - 1]
|
dp[i][j] = min(dp[i - 1][j - 1]
|
||||||
+ costOfSubstitution(x.charAt(i - 1), y.charAt(j - 1)),
|
+ costOfSubstitution(x.charAt(i - 1), y.charAt(j - 1)),
|
||||||
dp[i - 1][j] + 1, dp[i][j - 1] + 1);
|
dp[i - 1][j] + 1, dp[i][j - 1] + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return dp[x.length()][y.length()];
|
return dp[x.length()][y.length()];
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,21 +1,21 @@
|
||||||
package com.baeldung.algorithms.editdistance;
|
package com.baeldung.algorithms.editdistance;
|
||||||
|
|
||||||
public class EditDistanceRecursive extends EditDistanceBase {
|
public class EditDistanceRecursive extends EditDistanceBase {
|
||||||
|
|
||||||
static int calculate(String x, String y) {
|
static int calculate(String x, String y) {
|
||||||
|
|
||||||
if (x.isEmpty()) {
|
if (x.isEmpty()) {
|
||||||
return y.length();
|
return y.length();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (y.isEmpty()) {
|
if (y.isEmpty()) {
|
||||||
return x.length();
|
return x.length();
|
||||||
}
|
}
|
||||||
|
|
||||||
int substitution = calculate(x.substring(1), y.substring(1)) + costOfSubstitution(x.charAt(0), y.charAt(0));
|
int substitution = calculate(x.substring(1), y.substring(1)) + costOfSubstitution(x.charAt(0), y.charAt(0));
|
||||||
int insertion = calculate(x, y.substring(1)) + 1;
|
int insertion = calculate(x, y.substring(1)) + 1;
|
||||||
int deletion = calculate(x.substring(1), y) + 1;
|
int deletion = calculate(x.substring(1), y) + 1;
|
||||||
|
|
||||||
return min(substitution, insertion, deletion);
|
return min(substitution, insertion, deletion);
|
||||||
}
|
}
|
||||||
}
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue