This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Song(val filepath : String) { | |
| var title: String? = null | |
| var artist: String? = null | |
| var genre: String? = null | |
| var album: String? = null | |
| var year: Int? = null | |
| var duration: Double = 0.toDouble() | |
| var mediaInfo = MediaInfo() | |
| var lastModified: LocalDateTime? = null | |
| var rating : Double? = null |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| data class EquivalenceClass(val size : Long, val title : String?) | |
| fun findDuplicates(songs : List<Song>): Map<EquivalenceClass, List<Song>> { | |
| return songs.groupBy { EquivalenceClass(it.mediaInfo.size, it.title) } | |
| .filter { it.value.size > 1 } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Weapon | Type | Stats | |
|---|---|---|---|
| Rebel | SMG | 6/6/9/3/7 | |
| 87 | SHOTGUN | 2/10/1/5/6 | |
| Autocross | BOW | 6/6/6/6/6 | |
| Sixer | REVOLVER | 5/4/3/2/5 | |
| Mark IV | REVOLVER | 4/3/2/2/4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| BigDecimal percentRate = (currentAmount.divide(previousAmount, RoundingMode.HALF_EVEN) | |
| .subtract(BigDecimal.ONE)) | |
| .multiply(BigDecimal.valueOf(100)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| val percentRate = (currentAmount/ previousAmount - 1)*100 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Complex(val real: Double, val img: Double) { | |
| constructor(real: Number, img: Number) : this(real.toDouble(), img.toDouble()) | |
| operator fun unaryMinus() = Complex(-real, -img) | |
| operator fun plus(c: Complex) = Complex(real + c.real, img + c.img) | |
| operator fun plus(n: Number) = Complex(real + n.toDouble(), img) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| val c1 = Complex(2.0, -3.1) | |
| val c2 = Complex(-1.0, -2) | |
| val c3 = Complex(4.5, 1.2) | |
| val c4 = ((c1 + c2)*c2)/c4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Complex 0 = 0 + 0i | |
| */ | |
| val ZERO = Complex(0.0, 0.0) | |
| /** | |
| * Complex 1 = 1 + 0i | |
| */ | |
| val ONE = Complex(1.0, 0.0) | |
| /** | |
| * Complex unit = 0 + i |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| infix fun to(exponent: Int): Complex { | |
| if (exponent == 0) { | |
| return Complex(1.0, 0.0) | |
| } | |
| if (exponent == 1) { | |
| return this | |
| } | |
| val half = to(exponent / 2) | |
| return if (isEven(exponent)) { | |
| half * half |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters