From 0b1becafe0613ac17670b3bc51ece60b59bbeadc Mon Sep 17 00:00:00 2001 From: Simon Maertens Date: Thu, 30 Nov 2023 14:13:03 +0100 Subject: [PATCH] Changed some comments and fixed initialization script --- .../github/acimon33/aoc2023/day00/PuzzleBenchmark.kt | 8 +++++--- .../kotlin/com/github/acsimon33/aoc2023/day00/App.kt | 3 +-- .../aoc2023/day00/kotlinTemplate/KotlinTemplate.kt | 5 +++-- .../github/acsimon33/aoc2023/day00/ExampleTest.kt | 12 +++++++----- 2023/init.py | 2 -- 5 files changed, 16 insertions(+), 14 deletions(-) diff --git a/2023/00/kotlin_template/src/benchmarks/kotlin/com/github/acimon33/aoc2023/day00/PuzzleBenchmark.kt b/2023/00/kotlin_template/src/benchmarks/kotlin/com/github/acimon33/aoc2023/day00/PuzzleBenchmark.kt index 468ef784..4026c60f 100644 --- a/2023/00/kotlin_template/src/benchmarks/kotlin/com/github/acimon33/aoc2023/day00/PuzzleBenchmark.kt +++ b/2023/00/kotlin_template/src/benchmarks/kotlin/com/github/acimon33/aoc2023/day00/PuzzleBenchmark.kt @@ -1,29 +1,31 @@ package com.github.acsimon33.aoc2023.day00 -// Import Solution +// Import solution and benchmarking annotations import com.github.acsimon33.aoc2023.day00.kotlinTemplate.KotlinTemplate import java.io.File import java.util.concurrent.TimeUnit import org.openjdk.jmh.annotations.* -// Puzzle input +/** Puzzle input */ const val INPUT_FILENAME: String = "./input/puzzle_input.txt" +/** Benchmark framework */ @State(Scope.Benchmark) @Fork(1) @Warmup(iterations = 2) @Measurement(iterations = 2, time = 1, timeUnit = TimeUnit.SECONDS) open class PuzzleBenchmarks { - // KotlinTemplate App val app = KotlinTemplate(File(INPUT_FILENAME).readText(Charsets.UTF_8)) @Setup fun setUp() {} + /** First task benchmark */ @Benchmark fun task1() { app.solution1() } + /** Second task benchmark */ @Benchmark fun task2() { app.solution2() diff --git a/2023/00/kotlin_template/src/main/kotlin/com/github/acsimon33/aoc2023/day00/App.kt b/2023/00/kotlin_template/src/main/kotlin/com/github/acsimon33/aoc2023/day00/App.kt index e607c066..67ff8bba 100644 --- a/2023/00/kotlin_template/src/main/kotlin/com/github/acsimon33/aoc2023/day00/App.kt +++ b/2023/00/kotlin_template/src/main/kotlin/com/github/acsimon33/aoc2023/day00/App.kt @@ -1,7 +1,6 @@ package com.github.acsimon33.aoc2023.day00 -// Import CLI argument parser -// Import Solution +// Import solution and CLI argument parser import com.github.acsimon33.aoc2023.day00.kotlinTemplate.KotlinTemplate import com.github.ajalt.clikt.core.CliktCommand import com.github.ajalt.clikt.parameters.arguments.argument diff --git a/2023/00/kotlin_template/src/main/kotlin/com/github/acsimon33/aoc2023/day00/kotlinTemplate/KotlinTemplate.kt b/2023/00/kotlin_template/src/main/kotlin/com/github/acsimon33/aoc2023/day00/kotlinTemplate/KotlinTemplate.kt index 80ac9369..0525bd00 100644 --- a/2023/00/kotlin_template/src/main/kotlin/com/github/acsimon33/aoc2023/day00/kotlinTemplate/KotlinTemplate.kt +++ b/2023/00/kotlin_template/src/main/kotlin/com/github/acsimon33/aoc2023/day00/kotlinTemplate/KotlinTemplate.kt @@ -1,14 +1,15 @@ package com.github.acsimon33.aoc2023.day00.kotlinTemplate +/** Kotlin Template Solver */ public class KotlinTemplate(input: String) { val lines: List = input.lines() - /* First task. */ + /** First task */ fun solution1(): Int { return 0 } - /* Second task. */ + /** Second task */ fun solution2(): Int { return 1 } diff --git a/2023/00/kotlin_template/src/test/kotlin/com/github/acsimon33/aoc2023/day00/ExampleTest.kt b/2023/00/kotlin_template/src/test/kotlin/com/github/acsimon33/aoc2023/day00/ExampleTest.kt index b99bc6bd..5cce5bcf 100644 --- a/2023/00/kotlin_template/src/test/kotlin/com/github/acsimon33/aoc2023/day00/ExampleTest.kt +++ b/2023/00/kotlin_template/src/test/kotlin/com/github/acsimon33/aoc2023/day00/ExampleTest.kt @@ -1,25 +1,27 @@ package com.github.acsimon33.aoc2023.day00 -// Import Solution +// Import solution and testing framework import com.github.acsimon33.aoc2023.day00.kotlinTemplate.KotlinTemplate import java.io.File import kotlin.test.Test import kotlin.test.assertEquals -// Example input +/** Example input */ const val INPUT_FILENAME: String = "./input/example_input.txt" +/** Example test framework */ class ExampleTest { - // KotlinTemplate App val app = KotlinTemplate(File(INPUT_FILENAME).readText(Charsets.UTF_8)) + /** First task test */ @Test - fun task_1() { + fun task1() { assertEquals(app.solution1(), 0, "Example result for task 1 is wrong") } + /** Second task test */ @Test - fun task_2() { + fun task2() { assertEquals(app.solution2(), 1, "Example result for task 2 is wrong") } } diff --git a/2023/init.py b/2023/init.py index d7980565..521cc705 100755 --- a/2023/init.py +++ b/2023/init.py @@ -164,12 +164,10 @@ def main() -> None: last_line_matched = False add_workspace = False for line in file.readlines(): - print(line) if not add_workspace: add_workspace = last_line_matched m = re.match(r'include\("([0-9]{2}):([a-z_]*)"\)', line) if m and len(m.groups()) == 2: - print("lol") last_line_matched = True add_workspace = int(m.group(1)) > opts.day