|
| 1 | +package de.ronny_h.aoc.year2015.day05 |
| 2 | + |
| 3 | +import io.kotest.core.spec.style.StringSpec |
| 4 | +import io.kotest.matchers.shouldBe |
| 5 | + |
| 6 | +class InternElvesTest : StringSpec({ |
| 7 | + |
| 8 | + val internElves = InternElves() |
| 9 | + |
| 10 | + "part 1: A nice string contains at least three vowels" { |
| 11 | + internElves.hasThreeVowels("aei") shouldBe true |
| 12 | + internElves.hasThreeVowels("ugknbfddgicrmopn") shouldBe true |
| 13 | + } |
| 14 | + |
| 15 | + "part 1: A nice string contains at least one letter that appears twice in a row" { |
| 16 | + internElves.hasALetterTwiceInARow("ugknbfddgicrmopn") shouldBe true |
| 17 | + } |
| 18 | + |
| 19 | + "part 1: A nice string does not contain the strings ab, cd, pq, or xy" { |
| 20 | + internElves.doesNotContainBadStrings("ugknbfddgicrmopn") shouldBe true |
| 21 | + } |
| 22 | + |
| 23 | + "part 1: The number of nice strings" { |
| 24 | + internElves.part1(listOf("ugknbfddgicrmopn")) shouldBe 1 |
| 25 | + internElves.part1(listOf("aaa")) shouldBe 1 |
| 26 | + internElves.part1(listOf("jchzalrnumimnmhp", "haegwjzuvuyypxyu", "dvszwmarrgswjxmb")) shouldBe 0 |
| 27 | + } |
| 28 | + |
| 29 | + "part 2: A nice string contains a pair of any two letters that appears at least twice in the string without overlapping" { |
| 30 | + internElves.containsAPairOfLettersAtLeastTwiceWithoutOverlapping("xyxy") shouldBe true |
| 31 | + internElves.containsAPairOfLettersAtLeastTwiceWithoutOverlapping("aabcdefgaa") shouldBe true |
| 32 | + internElves.containsAPairOfLettersAtLeastTwiceWithoutOverlapping("aaa") shouldBe false |
| 33 | + } |
| 34 | + |
| 35 | + "part 2: A nice string contains at least one letter which repeats with exactly one letter between them" { |
| 36 | + internElves.containsALetterRepeatingWithExactlyOneLetterInBetween("xyx") shouldBe true |
| 37 | + internElves.containsALetterRepeatingWithExactlyOneLetterInBetween("abcdefeghi") shouldBe true |
| 38 | + internElves.containsALetterRepeatingWithExactlyOneLetterInBetween("abcdefeghi") shouldBe true |
| 39 | + internElves.containsALetterRepeatingWithExactlyOneLetterInBetween("aaa") shouldBe true |
| 40 | + internElves.containsALetterRepeatingWithExactlyOneLetterInBetween("abc") shouldBe false |
| 41 | + } |
| 42 | + |
| 43 | + "part 2: The number of nice strings" { |
| 44 | + internElves.part2(listOf("qjhvhtzxzqqjkmpb")) shouldBe 1 |
| 45 | + internElves.part2(listOf("xxyxx")) shouldBe 1 |
| 46 | + internElves.part2(listOf("uurcxstgmygtbstg", "uurcxstgmygtbstg")) shouldBe 0 |
| 47 | + } |
| 48 | +}) |
0 commit comments