Is there a way to get something like this `abstrac...
# advent-of-code
j
Is there a way to get something like this
abstract class AdventDay(input) { abstract fun test(input: Something): Int }
so that Something is either List<String> or Sequence<String> or String? And you can decide in the implementation which one you choose?
k
You could define an
InputProvider
that receives a name of a file, and then has a function for each type of output you'd like to receive, that's what I'd do
j
I tried messing with delegates and creating a class that is both a list and a sequence of strings, that works, but you can not also claim to be a String, since String is final
m
I have an interface with generics for the day, then intellij live template for the different kinds I might need on the day. Then a few basic test classes that can handle most of them. Utility functions to get the different input variants. But it is very custom to my template arrangement
m
I have a abstract class
AdventOfCodePuzzle
for that. Also capable of loading the input from a file named
input
from the same packages. (And I have script, which downloads my input to such a file) Feel free to look at: https://github.com/mcbeelen/aoc/blob/%F0%9F%8C%B1/util/src/main/kotlin/util/puzzle/AdventOfCodePuzzle.kt