Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 378d70d

Browse files
author
evitwilly
committed
added new algorithms: ParenthesisCheck and StringEqualsHash; edited some comments in other package
1 parent d714fc1 commit 378d70d

17 files changed

+213
-6
lines changed
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

‎.gradle/7.1/fileHashes/fileHashes.bin

1.03 KB
Binary file not shown.

‎.gradle/7.1/fileHashes/fileHashes.lock

0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

‎src/main/kotlin/other/Euclid.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
package other
22

33
/**
4+
*
45
* Euclid's algorithm for finding the greatest common divisor
56
*
67
*/
78

89
class Euclid {
910

1011
/**
12+
*
1113
* finds the greatest common divisor of two numbers
1214
*
1315
* @return returns the greatest common divisor
16+
*
1417
*/
1518
fun compute(num1: Int, num2: Int) : Int {
1619
var copyNum1 = num1

‎src/main/kotlin/other/LevensteinLength.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,19 @@ package other
33
import java.lang.Integer.min
44

55
/**
6+
*
67
* Algorithm for determining the Levenshtein distance
78
*
89
*/
910

1011
class LevenshteinLength {
1112

1213
/**
14+
*
1315
* determines the Levenshtein distance for two strings and returns it
1416
*
1517
* @return returns the Levenshtein distance for two strings
18+
*
1619
*/
1720
fun compute(str1: String, str2: String) : Int {
1821
val matrix = Array(str1.length + 1) {
@@ -39,4 +42,5 @@ class LevenshteinLength {
3942

4043
return matrix[str1.length][str2.length]
4144
}
45+
4246
}

‎src/main/kotlin/other/Max.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class Max<T : Comparable<T>> {
1212
/**
1313
*
1414
* @return returns the maximum element from the list
15+
*
1516
*/
1617
fun compute(items: List<T>) : T {
1718
if (items.isEmpty()) {
@@ -29,6 +30,7 @@ class Max<T : Comparable<T>> {
2930
/**
3031
*
3132
* @return returns the maximum element from the list recursively
33+
*
3234
*/
3335
fun computeRecursive(items: List<T>) : T {
3436
if (items.size == 1) {

‎src/main/kotlin/other/Palindrome.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,27 @@
11
package other
22

33
/**
4+
*
45
* Algorithm for checking a string for a palindrome
56
*
67
*/
78

89
class Palindrome(private val text: String) {
910

1011
/**
12+
*
1113
* checks a string for a palindrome
1214
*
1315
* @return returns true if the string is a palindrome
16+
*
1417
*/
1518
fun isYes() = text == text.reversed()
1619

1720
/**
1821
* checks if a string is not a palindrome
1922
*
2023
* @return returns true if the string is not a palindrome
24+
*
2125
*/
2226
fun isNot() = !isYes()
2327

‎src/main/kotlin/other/PalindromeAdvanced.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
package other
22

33
/**
4+
*
45
* Algorithm for checking a string for a palindrome
56
*
67
*/
78

89
class PalindromeAdvanced(private val text: String) {
910

1011
/**
12+
*
1113
* checks a string for a palindrome
1214
*
1315
* @return returns true if the string is a palindrome
16+
*
1417
*/
1518
fun isYes() : Boolean {
1619
if (text.length <= 1) {
@@ -25,9 +28,11 @@ class PalindromeAdvanced(private val text: String) {
2528
}
2629

2730
/**
31+
*
2832
* checks if a string is not a palindrome
2933
*
3034
* @return returns true if the string is not a palindrome
35+
*
3136
*/
3237
fun isNot() = !isYes()
3338

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /