You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+104-2
Original file line number
Diff line number
Diff line change
@@ -15,10 +15,112 @@ After creating a new project based on this template in your account, a dedicated
15
15
It will also personalize code to use your username and project name in namespaces and Gradle properties.
16
16
How cool is that?
17
17
18
-
Right after the @actions-user actor pushes the second commit to your repository, you're ready to clone it within the IntelliJ IDEA.
18
+
Right after the [@actions-user][actions-user] actor pushes the second commit to your repository, you're ready to clone it within the IntelliJ IDEA.
19
19
20
-
![file:kotlin]
20
+
From now, everything's in your hands!
21
+
Join the [Advent of Code][aoc] contest, solve the Day O1 as soon as it is published.
21
22
23
+
For the following days, copy the `Day01.kt` solution file, its `Day01Test.kt` tests, and name it with an incremented day.
24
+
25
+
> Remember to join the Kotlin contest!
26
+
>
27
+
> To do that, edit your project's _About_ section with ⚙️ icon and add the `aoc-2021-in-kotlin` topic to your project.
28
+
>
29
+
> **We will find your repository and count you in our giveaway.**
30
+
31
+
## Content
32
+
33
+
After you create a new project based on the current template repository using the **Use this template** button, a bare minimal scaffold will appear in your GitHub account with the following structure:
34
+
35
+
```
36
+
.
37
+
├── README.md README file
38
+
├── build.gradle.kts Gradle configuration created with Kotlin DSL
│ │ ├── Day.kt Base class for Day* implementations
50
+
│ │ ├── Day01.kt An empty implementation for the first AoC day
51
+
│ │ └── utils
52
+
│ │ ├── Resources.kt Utility class for loading input txt files
53
+
│ │ └── utils.kt A set of utility methods shared across your classes
54
+
│ └── resources
55
+
│ └── day01.txt An empty file for the Day 01 input data
56
+
└── test
57
+
└── kotlin
58
+
└── com.github.you.project
59
+
├── DayTest.kt Base test class
60
+
└── Day01Test.kt Class to test your implementation against test data
61
+
```
62
+
63
+
After the first puzzle appears, go to the `Day01.kt` and for each `part1` and `part2` classes, provide an algorithm implementation using the provided `input` data loaded from the `day01.txt` file.
64
+
This input data is common for both parts, and you can find it on the bottom of each day on the [Advent of Code][aoc] page.
65
+
66
+
To read the input data as a list of strings, you can go with the `String.ints()` utility method provided in the [`utils.kt`][file:utils] file, like:
67
+
68
+
```kotlin
69
+
classDay01 : Day(1) {
70
+
71
+
overridefunpart1(input:String): Int {
72
+
return input.ints().sum()
73
+
}
74
+
75
+
// ...
76
+
}
77
+
```
78
+
79
+
This file also contains the `String.md5()` method for generating MD5 has out of the given string and expects more helper functions for the sake of the [KISS principle][kiss].
80
+
81
+
To check if everything works as expected during the development, you can use the test data and answers within each day's story and provide them for your `DayTest` test implementation.
82
+
You may want to run such a test case by clicking the _Test All Days_ Run/Debug Configuration provided in the top-right toolbar or check the test result for each day separately.
83
+
84
+
To go with the next day, place the `day02.txt` file into the `resources` with relevant input data, create `Day02.kt` file with the class implementation:
85
+
86
+
```kotlin
87
+
classDay02 : Day(2) {
88
+
// ...
89
+
}
90
+
```
91
+
92
+
Then just provide tests for the second day in a similar manner:
93
+
94
+
```kotlin
95
+
classDay02Test : DayTest() {
96
+
97
+
overrideval day =Day02()
98
+
99
+
@Test
100
+
overridefun`Part 1`() {
101
+
assertEquals(0, day.part1("test_input")) // check against test input
102
+
assertEquals(0, day.part1()) // check solution against input data
103
+
}
104
+
105
+
// ...
106
+
}
107
+
```
108
+
109
+
## Getting help
110
+
111
+
If you stuck with Kotlin-specific questions or anything related to this template, check out the following resources:
0 commit comments