Skip to content

Commit b0c2ea0

Browse files
committed
Update README file
1 parent 7617bdc commit b0c2ea0

File tree

1 file changed

+104
-2
lines changed

1 file changed

+104
-2
lines changed

README.md

+104-2
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,112 @@ After creating a new project based on this template in your account, a dedicated
1515
It will also personalize code to use your username and project name in namespaces and Gradle properties.
1616
How cool is that?
1717

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.
1919

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.
2122

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
39+
├── gradle
40+
│ └── wrapper Gradle Wrapper
41+
├── gradle.properties Gradle configuration properties
42+
├── gradlew *nix Gradle Wrapper script
43+
├── gradlew.bat Windows Gradle Wrapper script
44+
├── settings.gradle.kts Gradle project settings
45+
└── src
46+
├── main
47+
│ ├── kotlin
48+
│ │ └── com.github.you.project
49+
│ │ ├── 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+
class Day01 : Day(1) {
70+
71+
override fun part1(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+
class Day02 : Day(2) {
88+
// ...
89+
}
90+
```
91+
92+
Then just provide tests for the second day in a similar manner:
93+
94+
```kotlin
95+
class Day02Test : DayTest() {
96+
97+
override val day = Day02()
98+
99+
@Test
100+
override fun `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:
112+
113+
- [Kotlin docs][docs]
114+
- [Kotlin Slack][slack]
115+
- Template [issue tracker][issues]
116+
117+
118+
[actions-user]: https://github.com/actions-user
22119
[aoc]: https://adventofcode.com
120+
[docs]: https://kotlinlang.org/docs/home.html
121+
[issues]: https://github.com/kotlin-hands-on/advent-of-code-kotlin-template/issues
122+
[kiss]: https://en.wikipedia.org/wiki/KISS_principle
23123
[kotlin]: https://kotlinlang.org
124+
[slack]: https://surveys.jetbrains.com/s3/kotlin-slack-sign-up
24125
[file:kotlin]: .github/readme/kotlin.svg
126+
[file:utils]: src/main/kotlin/com/github/kotlinhandson/aoc/utils/utils.kt

0 commit comments

Comments
 (0)