Thanks to visit codestin.com
Credit goes to github.com

Skip to content

pgebert/advent-of-code-kotlin-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

12 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Current day Stars obtained Days completed

Daily Solution Index

Day Title Part 1 Part 2 Code
βœ” 01 (not released) ⭐ ⭐ Code
βšͺ 02 (not released) βšͺ βšͺ Code
βšͺ 03 (not released) βšͺ βšͺ Code
βšͺ 04 (not released) βšͺ βšͺ Code
βšͺ 05 (not released) βšͺ βšͺ Code
βšͺ 06 (not released) βšͺ βšͺ Code
βšͺ 07 (not released) βšͺ βšͺ Code
βšͺ 08 (not released) βšͺ βšͺ Code
βšͺ 09 (not released) βšͺ βšͺ Code
βšͺ 10 (not released) βšͺ βšͺ Code
βšͺ 11 (not released) βšͺ βšͺ Code
βšͺ 12 (not released) βšͺ βšͺ Code
βšͺ 13 (not released) βšͺ βšͺ Code
βšͺ 14 (not released) βšͺ βšͺ Code
βšͺ 15 (not released) βšͺ βšͺ Code
βšͺ 16 (not released) βšͺ βšͺ Code
βšͺ 17 (not released) βšͺ βšͺ Code
βšͺ 18 (not released) βšͺ βšͺ Code
βšͺ 19 (not released) βšͺ βšͺ Code
βšͺ 20 (not released) βšͺ βšͺ Code
βšͺ 21 (not released) βšͺ βšͺ Code
βšͺ 22 (not released) βšͺ βšͺ Code
βšͺ 23 (not released) βšͺ βšͺ Code
βšͺ 24 (not released) βšͺ βšͺ Code
βšͺ 25 (not released) βšͺ βšͺ Code

How to use this template

Getting Started

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:

  • inputString: the input data as one string
  • inputList: the input data splitted into lines

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() }
}

3. Update tests

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.

Additional notes

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
}

Miscellaneous

🀝 Contributing

Contributions, issues and feature requests are welcome!

Show your support

Give a ⭐️ if this project helped you!