A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pgebert/advent-of-code-kotlin-template below:

pgebert/advent-of-code-kotlin-template: Advent of code template for kotlin.

1. Download daily input data

Copy your daily input data from the advent of code page to the corresponding *.txt file in src/main/resources.

2. Implement your solution

Use the prepared solution classes under src/main/kotlin/days and implement the method stubs for partOne and partTwo. Each day has two properties:

So your solution can be implemented in the following way:

object Day01 : Day(1, "Day1") {

    override fun partOne() = inputString.doSomething()

    override fun partTwo() = inputList.map { it.doSomething() }
}

This step is optional, but it's a nice way to proof that your solution is valid:

Extend the test factory in src/test/kotlin/de/pgebert/aoc/DaysTest.kt.

Testing with example data

By default, the input is read from the input file of the corresponding day, but for development it can be useful to test against the provided example input. This can be achieved very easily:

    @Test
fun `testing day 01 example`() {
    val example = """
            1abc2
            pqr3stu8vwx
            a1b2c3d4e5f
            treb7uchet
        """

    val day = Day01(input = example)

    day.partOne() shouldBe 142
}

Contributions, issues and feature requests are welcome!

Give a ⭐️ if this project helped you!


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4