Coder Social home page Coder Social logo

jfkriz / adventofcode-2022 Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 240 KB

Advent of Code - 2022

License: BSD 3-Clause "New" or "Revised" License

Kotlin 100.00%
advent-of-code aoc-2022-in-kotlin kotlin advent-of-code-2022-kotlin advent-of-code-2022 aoc2022

adventofcode-2022's Introduction

๐ŸŽ„ Advent Of Code 2022 ๐ŸŽ„

My solutions for the Advent of Code - 2022

๐ŸŒŸ My Awesome Badges! ๐ŸŒŸ

Advent of Code 2022 - Run Tests

Usage

Create each Day's solutions in a structure like this under src/test/kotlin:

./day01 +
        |
        +- CalorieCounterTest.kt
        +- input.txt
        +- test-input.txt
        +- README.md
./day02 +
        |
        +- Day02Test.kt
        +- input.txt
        +- test-input.txt
        +- README.md
./dayNN +
        |
        +- TodayTest.kt
        +- input.txt
        +- test-input.txt
        +- README.md

Assuming each day's solutions follow the above directory structure and naming conventions, you will be able to run each solution with a command like:

./gradlew run test --tests="day01**"

If the tests are named appropriately, you can also use a command like this to just run a specific test:

./gradlew run test --tests="day01**Part 1**Sample**"

This would run just the Part One solution for the Sample input (test-input.txt).

For each new Day, you can simply copy the "template" dayNN package, and rename/implement as appropriate, or follow these destructions...

  • Create a dayNN directory
  • In the dayNN directory, create a SomethingTest.kt for the tests for the challenges. Naming the tests appropriately will allow the above gradle commands to work as described.
package dayNN

import Helpers
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.DisplayName
import org.junit.jupiter.api.Test

@DisplayName("Day N - Description")
class TodayTest : Helpers() {
    @Test
    fun `Day 1 Part 1 Sample Input should return 42`() {
        assertEquals(42, Solver(loadSampleInput()).solvePartOne())
    }

    @Test
    fun `Day 1 Part 2 Sample Input should return 90210`() {
        assertEquals(90210, Solver(loadSampleInput()).solvePartTwo())
    }

    @Test
    fun `Day 1 Part 1 Real Input should return 42`() {
        assertEquals(42, Solver(loadInput()).solvePartOne())
    }

    @Test
    fun `Day 1 Part 2 Real Input should return 90210`() {
        assertEquals(90210, Solver(loadInput()).solvePartTwo())
    }
}

class Solver(data: List<String>) {
    fun solvePartOne(): Int {
        return 42
    }

    fun solvePartTwo(): Int {
        return 90210
    }
}
  • In the dayNN directory, create an input.txt file with the input for the challenge; optionally create a test-input.txt with the sample input, for easier testing
  • Copy the source of the final HTML page after solving both challenges, and paste into CodeBeautify to get a markdown version of the page
  • Add a README each day, with the markdown from CodeBeautify
  • Commit the day's solution, only after the day is over.
  • The .gitignore should keep the input.txt from being committed, but please be sure to not commit this, per the author's request

adventofcode-2022's People

Contributors

dependabot[bot] avatar jfkriz avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.