I'm starting with this template I was suggested: <...
# advent-of-code
s
I'm starting with this template I was suggested: https://github.com/stkent/AdventOfCode2019Template. But, how do I actually use it? How do I set it up so that the file is read in?
s
@Steve Copy the input from the website into the file day01/src/main/resources/input.txt.
Then in day01/src/main/kotlin/Main.kt, inside the
main
function, you can write something like
val input = File(ClassLoader.getSystemResource("input.txt").file).readLines()
to read in all the lines of the input file as strings
s
thanks
👍 1
do you use the Test directories for anything, or were they just auto-generated?
s
Dependencies are set up for JUnit 5 unit tests
(mild spoilers in the test names^)
t
Arrange... Act... Assert... is new to me. That seems like itmore accurately describes Given/When/Then. I might have to thnk about switching.
s
I often find myself artificially twisting words around to describe GWT test cases; I like that AAA covers the same ground but allows a little bit more freedom of implementation!
s
@stkent I'm really sorry to keep bothering you, but I have no idea how to add a utils module to that project, and I'm tearing my hair out trying
s
No worries @Steve! Let me walk through it on my machine so I know the information I'm about to post is good
s
thank you
s
Ok, first create a new module using IntelliJ's helper:
Configure it with this options:
Then for any day you want to use your utils, edit the file
dayXX/build.gradle.kts
and add
implementation(project(":utils"))
right below
implementation(kotlin("stdlib-jdk8"))
Sync with Gradle and you should then have access to code in the
utils/src/main/kotlin
sources from your dayXX code!
s
Thank you. I was choosing a new Kotlin module, not a Gradle module using Kotlin. I'll try that now
s
Yeah, that's a bit of a trap, I've fallen into it before 🙂