A template for Advent of Code challenge with input downloading and prepared test classes

Overview

Advent of Code Kotlin Template

A template which will help you concentrate on the puzzle solutions. It brings

  • Downloading and caching of the puzzle input
  • A place to enter your puzzle solving code. Results are printed and the time gets measured.
  • Tests to check your puzzle solving code against the example data you get each day.

Screenshot

Setup

  • Click 'Use this template'
  • Clone your new repository
  • Open the project with IntelliJ Idea CE (recommended)

Set up the automatic input download

The setup process differs depending on how you are planning to execute your solutions.

  1. Via gradle from the command line
  2. Via the run button in IntelliJ

Either way, you will have to determine your session cookie beforehand.

The downloader tries to download the input for the current year. If you want to use this template for older puzzles you have to adjust it accordingly.

0. Determine your session cookie

  • Open adventofcode.com in your browser
  • Login
  • Open the developer tools
  • Open the storage tab
  • Select "Cookies" → "https://adventofcode.com"
  • A table will open, the row with the name "session" is the correct one, the session cookie is the string in the "Value" field

1. Via gradle from the command line

  • Setup (only needed once)
    1. Create the file ./gradle.properties
    2. Insert the line sessionCookie=yourSessionCookieWithoutQuotes
  • Execution for a day
    • Execute ./gradlew run -Dday={day number}

Alternatively you could skip the setup and pass the cookie as a parameter: ./gradlew run -Dday={day number} -DsessionCookie={session cookie}"

2. Via the run button in IntelliJ

  1. Open one of the Day{XY}.kt files
  2. Click the play button next to the main function, select Modify run configuration
  3. Insert your session cookie into the field Program arguments
  4. Execute the day by clicking the run button again and select Run

You have to repeat this for each day. Or you edit your run configuration each day to execute a different main function.

Tests

Tests are prepared. They are written with KoTest.
Please make sure to install the KoTest IntelliJ Idea plugin from the plugin repository in the settings.

Each day you can insert the given example data and solution into the according test class. Running the tests will check if your solution will result in the correct answer.

You can execute the tests with one of these options:

  • Click the play button next to the test class or method (KoTest plugin required)
  • Select and run the according run configuration
  • Execute ./gradlew :app:test --tests "day{XY}.Day{XY}Test"

If you want to write more tests along the way:

You might also like...
My solutions for Advent of Code 2021, written in Kotlin!

Advent-of-Code-2021 Welcome to the Advent of Code1 Kotlin project created by thijsboehme using the Advent of Code Kotlin Template delivered by JetBrai

Kotlin fun with Advent of Code 2021

aoc-kotlin Welcome to the Advent of Code1 Kotlin project created by dayanruben using the Advent of Code Kotlin Template delivered by JetBrains. In thi

Advent of Code 2021 implementations in Kotlin

advent-of-code-in-kotlin-2021 Welcome to the Advent of Code1 Kotlin project created by acrane13 using the Advent of Code Kotlin Template delivered by

Advent of Code 2021: Solutions in Kotlin

Advent of Code 2021 Solutions in Kotlin This repo is my personal attempt at solving the Advent of Code 2021 set of problems with the Kotlin programmin

Advent of Code 2021, using Kotlin

Advent of Code 2021, using Kotlin See https://adventofcode.com/2021, https://kotlinlang.org/. See also "the official GitHub template" by JetBrains. Ge

Advent of Code 2020 - Kotlin

* , _/^\_ * /.-.\ * * `/&\` *

Repository for solving Advent of Code in Kotlin.

Advent of Code 2021 Repository for solving Advent of Code in Kotlin. Getting started Running Project is already setup with gradle. To run the app: Nav

Advent of Code project 2021!

aoc-2021 Welcome to the Advent of Code1 Kotlin project created by goddabuzz using the Advent of Code Kotlin Template delivered by JetBrains. In this r

Advent of Code 2021 in Kotlin Multiplatform!

Advent of Code 2021 in Kotlin Multiplatform Structure Each day comes with two parts for you to solve. You'll find a ready-to go and test templates to

Owner
Henning B
Henning B
Solution to the 2021 Advent of code challenge in Kotlin. aoc-2021-in-kotlin

advent-of-code-2021 Welcome to the Advent of Code1 Kotlin project created by aniobistanley using the Advent of Code Kotlin Template delivered by JetBr

null 0 Dec 24, 2021
Nab-challenge - Take home challenge from NAB in partnership with Positive Thinking Company

nab-challenge Take home challenge from NAB in partnership with Positive Thinking

Hieu Vu 0 Dec 30, 2021
Android-coding-challenge - Vien Health Android coding challenge

Vien Health Android coding challenge Tasks There's a series of tasks to complete

Ezekiel Sebastine 1 Jun 27, 2022
Advent of Code template project for Kotlin

Advent of Code Kotlin Template Advent of Code – an annual event in December since 2015. Every year since then, with the first day of December, a progr

Kotlin Hands-On Labs 336 Dec 23, 2022
Tkhwang advent of code kotlin template

tkhwang-advent-of-code-kotlin-template Welcome to the Advent of Code1 Kotlin pro

Teddy 0 Jan 8, 2022
A simple app to test your device input sample rate.

Android touch sample rate test tool This tool can help you check the touch sample rate of the Android device. Supported input method: Touch Mouse Styl

samnyan 4 Sep 28, 2022
code for the Mobiquity QA challenge assignment

MOBIQUITY QA CODE CHALLENGE This repository contains the code for Mobiquity code assignment for the Senior QA engineer position. Tech Stack the tools

ricardo larrahondo 1 Jan 3, 2022
Clean Architecture Kotlin Multiplatform Mobile (KMM) with Android Instrument Test and Unit Test

The-Movies: Clean Architecture Kotlin Multiplatform Mobile What're inside? - Jetpack Compose - Hilt - Ktor - Android Instrument Test - Unit Test - SQL

null 17 Dec 5, 2022
My Advent of Code solutions written in Kotlin

AOC21 My Advent of Code solutions written in Kotlin Why Kotlin? I think Kotlin is a really suitable language for Advent of Code, because it handles li

Chris 2 Dec 14, 2021
My solutions for Advent of Code 2021 puzzles, mainly using Kotlin.

Advent of Code 2021 Featuring Kotlin What's that ? https://adventofcode.com/2021/about Advent of Code is an Advent calendar of small programming puzzl

Petrole 0 Dec 2, 2021