Skip to content

Commit

Permalink
Changed some comments and fixed initialization script
Browse files Browse the repository at this point in the history
  • Loading branch information
ACSimon33 committed Nov 30, 2023
1 parent 19fdc7a commit 0b1beca
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -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()
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package com.github.acsimon33.aoc2023.day00.kotlinTemplate

/** Kotlin Template Solver */
public class KotlinTemplate(input: String) {
val lines: List<String> = input.lines()

/* First task. */
/** First task */
fun solution1(): Int {
return 0
}

/* Second task. */
/** Second task */
fun solution2(): Int {
return 1
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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")
}
}
2 changes: 0 additions & 2 deletions 2023/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 0b1beca

Please sign in to comment.