diff --git a/pom.xml b/pom.xml index 8e4a1ab..0241b46 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ 1.0-SNAPSHOT - 1.2.0 + 1.2.31 diff --git a/src/main/kotlin/CaptchaResolver.kt b/src/main/kotlin/CaptchaResolver.kt deleted file mode 100644 index ee96840..0000000 --- a/src/main/kotlin/CaptchaResolver.kt +++ /dev/null @@ -1,45 +0,0 @@ -class CaptchaResolver { - - fun resolvePartOne(input: String): Int { - val iterator = input.split("").filter({ s -> s != "" }).listIterator() - var last: Int = -1 - var current: Int - var sum = 0 - - while (iterator.hasNext()) { - current = iterator.next().toInt() - if (current == last) { - sum += current - } - last = current - } - if (last == input.split("")[1].toInt()) { - sum += last - } - return sum - } - - fun resolvePartTwo(input: String): Int { - var sum = 0 - val inputList = input.split("").filter({ s -> s != "" }) - - for ((index, s) in inputList.withIndex()) { - val digit = s.toInt() // 0 | 1 | 2 - val calculateIndex = calculateIndex(inputList.size, index) //2 | 3 | 4 - val foundDigit = inputList[calculateIndex].toInt() - if (foundDigit == digit) { - sum += digit - } - } - return sum - } - - private fun calculateIndex(max: Int, actualIndex: Int): Int { - val exceedsMax = actualIndex + max / 2 >= max - if (exceedsMax) { - return (max - actualIndex - max / 2).unaryMinus() - } - return actualIndex + max/2 - } - -} \ No newline at end of file diff --git a/src/test/kotlin/BlockBalanceTest.kt b/src/test/kotlin/BlockBalanceTest.kt index eeaabb5..8e0c9b6 100644 --- a/src/test/kotlin/BlockBalanceTest.kt +++ b/src/test/kotlin/BlockBalanceTest.kt @@ -7,9 +7,9 @@ import org.junit.Assert.assertEquals class BlockBalanceTest : Spek({ describe("A block balancer") { on("the input of 0 2 7 0") { - it("should return 5") { + it("should return 4") { val redistributions = BlockBalancer().findInfiniteLoop("0\t2\t7\t0") - assertEquals(5, redistributions) + assertEquals(4, redistributions) } } } diff --git a/src/test/kotlin/CaptchaResolverTest.kt b/src/test/kotlin/CaptchaResolverTest.kt index 939abcc..65034a0 100644 --- a/src/test/kotlin/CaptchaResolverTest.kt +++ b/src/test/kotlin/CaptchaResolverTest.kt @@ -1,3 +1,4 @@ +import day1.CaptchaResolver import junit.framework.TestCase.assertEquals import org.jetbrains.spek.api.Spek import org.jetbrains.spek.api.dsl.describe @@ -8,7 +9,7 @@ import org.junit.runner.RunWith @RunWith(JUnitPlatform::class) class CaptchaResolverTest: Spek({ - describe("a CaptchaResolver") { + describe("a day1.CaptchaResolver") { val resolver = CaptchaResolver() on("the given input of 1111 and usage of resolver one") { it("should return 4") { diff --git a/src/test/kotlin/LabyrinthEscapeTest.kt b/src/test/kotlin/LabyrinthEscapeTest.kt index ec99b7d..cb457f2 100644 --- a/src/test/kotlin/LabyrinthEscapeTest.kt +++ b/src/test/kotlin/LabyrinthEscapeTest.kt @@ -11,13 +11,13 @@ class LabyrinthEscapeTest : Spek({ describe("A labyrinth escaper") { on("the given input of [(0) 3 0 1 -3]") { - it("should return 5 (steps)") { + it("should return 10 (steps)") { val result = LabyrinthEscape().calculateSteps("0\n" + "3\n" + "0\n" + "1\n" + "-3") - assertEquals(5, result) + assertEquals(10, result) } } } diff --git a/src/test/kotlin/PassPhraseValidatorTest.kt b/src/test/kotlin/PassPhraseValidatorTest.kt index cea0273..568bc6f 100644 --- a/src/test/kotlin/PassPhraseValidatorTest.kt +++ b/src/test/kotlin/PassPhraseValidatorTest.kt @@ -32,6 +32,9 @@ class PassPhraseValidatorTest : Spek({ } } + + + on("the input of 'aa bb cc dd aaa \n aa bb cc dd aa'") { it("should return 1") { val result = PassphraseValidator().validate("aa bb cc dd aaa") diff --git a/src/test/kotlin/TowersTest.kt b/src/test/kotlin/TowersTest.kt index 1f2b054..d7f65fd 100644 --- a/src/test/kotlin/TowersTest.kt +++ b/src/test/kotlin/TowersTest.kt @@ -2,8 +2,11 @@ import org.jetbrains.spek.api.Spek import org.jetbrains.spek.api.dsl.describe import org.jetbrains.spek.api.dsl.it import org.jetbrains.spek.api.dsl.on +import org.junit.platform.runner.JUnitPlatform +import org.junit.runner.RunWith import kotlin.test.assertEquals +@RunWith(JUnitPlatform::class) class TowersTest : Spek({ val testInput = "pbga (66)\n" +