Skip to content

Commit a2abe90

Browse files
committed
doc: upate readme
1 parent 975c6d5 commit a2abe90

File tree

1 file changed

+4
-121
lines changed

1 file changed

+4
-121
lines changed

README.md

Lines changed: 4 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -1,126 +1,9 @@
1-
# Advent of Code Kotlin Template
1+
# Advent of Code Kotlin 2022
22

3-
[Advent of Code][aoc] – an annual event in December since 2015.
4-
Every year since then, with the first day of December, a programming puzzles contest is published every day for twenty-four days.
5-
A set of Christmas-oriented challenges provide any input you have to use to answer using the language of your choice.
6-
We offer you a template prepared to use with [Kotlin][kotlin] language within this repository.
3+
Notes:
74

8-
![][file:cover]
5+
1. questiosn from: https://adventofcode.com/
6+
2. IntelliJ IDEA template from kotlin-hands-on/advent-of-code-kotlin-template
97

10-
## Workflow
11-
**Advent of Code Kotlin Template** is a particular type of GitHub repository that lets you speed up the setup phase and start writing your AoC solutions immediately.
128

13-
The general idea is straightforward – to create a new project based on this template, you need to log in to your GitHub account and use the **Use this template** green button.
14-
And remember – **do not fork it!**
159

16-
After creating a new project based on this template in your account, a dedicated GitHub Actions workflow will start and clean up the code from redundant files.
17-
It will also personalize code to use your username and project name in namespaces and Gradle properties.
18-
How cool is that?
19-
20-
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.
21-
22-
From now, everything's in your hands!
23-
Join the [Advent of Code][aoc] contest, solve the Day O1 as soon as it is published.
24-
25-
For the following days, copy the `Day01.kt` solution file and increment the day number.
26-
27-
> Remember to join the Kotlin contest!
28-
>
29-
> To do that, edit your project's _About_ section with ⚙️ icon and add the `aoc-2022-in-kotlin` topic to your project.
30-
>
31-
> **We will find your repository and count you in our giveaway.**
32-
33-
## Content
34-
35-
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:
36-
37-
```
38-
.
39-
├── README.md README file
40-
├── build.gradle.kts Gradle configuration created with Kotlin DSL
41-
├── gradle
42-
│ └── wrapper Gradle Wrapper
43-
├── gradle.properties Gradle configuration properties
44-
├── gradlew *nix Gradle Wrapper script
45-
├── gradlew.bat Windows Gradle Wrapper script
46-
├── settings.gradle.kts Gradle project settings
47-
└── src
48-
├── Day01.kt An empty implementation for the first AoC day
49-
├── Day01.txt An empty file for the Day 01 input data
50-
├── Day01_test.txt An optional Day 01 test input data used for checks
51-
└── Utils.kt A set of utility methods shared across your days
52-
```
53-
54-
> Note: All task input files are excluded from the repository with `.gitignore` – we should not post them publicly, as Eric Wastl asks for: [Tweet](https://twitter.com/ericwastl/status/1465805354214830081).
55-
56-
When the first puzzle appears, go to the `Day01.kt` and for each `part1` and `part2` functions, provide an algorithm implementation using the `input` data loaded from the `src/Day01.txt` file.
57-
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.
58-
59-
To read the input data, you can go with the `readInput(name: String)` utility method provided in the [`Utils.kt`][file:utils] file, like:
60-
61-
```kotlin
62-
fun main() {
63-
fun part1(input: List<String>): Int {
64-
return input.size
65-
}
66-
67-
val input = readInput("Day01")
68-
println(part1(input))
69-
}
70-
```
71-
72-
The [`Utils.kt`][file:utils] file also contains the `String.md5()` method for generating MD5 hash out of the given string and expects more helper functions for the sake of the [KISS principle][kiss].
73-
74-
Each puzzle describes some test conditions, a small portion of the information that helps check if the produced value for the given test input is valid.
75-
To handle that case, you can put such an input into a separated file and perform a check against the output, like:
76-
77-
```kotlin
78-
fun main() {
79-
// ...
80-
81-
val testInput = readInput("Day01_test")
82-
check(part1(testInput) == 13)
83-
}
84-
```
85-
86-
The current approach of providing both `part1` and `part2` solutions within the single `Day##.kt` file may sometimes bring a disadvantage due to the first solution calculation when we expect to work on the second part only.
87-
With simple cases that don't consume too much of your time and resources that can be almost unnoticeable, but when solution takes seconds, it is worth considering breaking daily solution into two separated pieces, like `Day07_part1.kt` and `Day07_part2.kt`.
88-
89-
The final result of your algorithm will be printed on the screen so that you can pass it to the Advent of Code website.
90-
91-
To go with the next day, place the `Day02.txt` file into the `src` with relevant input data and create `Day02.kt` file with a similar code scaffold:
92-
93-
```kotlin
94-
fun main() {
95-
fun part1(input: List<String>): Int {
96-
return 0
97-
}
98-
99-
fun part2(input: List<String>): Int {
100-
return 0
101-
}
102-
103-
val input = readInput("Day02")
104-
println(part1(input))
105-
println(part2(input))
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
119-
[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
123-
[kotlin]: https://kotlinlang.org
124-
[slack]: https://surveys.jetbrains.com/s3/kotlin-slack-sign-up
125-
[file:cover]: .github/readme/cover.png
126-
[file:utils]: src/Utils.kt

0 commit comments

Comments
 (0)