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
+20-18
Original file line number
Diff line number
Diff line change
@@ -46,32 +46,34 @@ After you create a new project based on the current template repository using th
46
46
├── Day01.kt An empty implementation for the first AoC day
47
47
├── Day01.txt An empty file for the Day 01 input data
48
48
├── Day01_test.txt An optional Day 01 test input data used for assertion
49
-
└── utils.kt A set of utility methods shared across your days
49
+
└── Utils.kt A set of utility methods shared across your days
50
50
```
51
51
52
52
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.
53
53
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.
54
54
55
-
To read the input data, you can go with the `readInput(name: String)` utility method provided in the [`utils.kt`][file:utils] file, like:
55
+
To read the input data, you can go with the `readInput(name: String)` utility method provided in the [`Utils.kt`][file:utils] file, like:
56
56
57
57
```kotlin
58
-
funpart1(input:List<String>): Int {
59
-
return input.size
60
-
}
61
-
62
58
funmain() {
59
+
funpart1(input:List<String>): Int {
60
+
return input.size
61
+
}
62
+
63
63
val input = readInput("Day01")
64
-
part1(input).also(::println)
64
+
println(part1(input))
65
65
}
66
66
```
67
67
68
-
The [`utils.kt`][file:utils] 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].
68
+
The [`Utils.kt`][file:utils] 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].
69
69
70
70
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.
71
71
To handle that case, you can put such an input into a separated file and perform a standard assertion against the output, like:
72
72
73
73
```kotlin
74
74
funmain() {
75
+
// ...
76
+
75
77
val testInput = readInput("Day01_test")
76
78
assert(part1(testInput) ==13)
77
79
}
@@ -82,18 +84,18 @@ The final result of your algorithm will be printed on the screen so that you can
82
84
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:
83
85
84
86
```kotlin
85
-
funpart1(input:List<String>): Int {
86
-
return0
87
-
}
87
+
funmain() {
88
+
funpart1(input:List<String>): Int {
89
+
return0
90
+
}
88
91
89
-
funpart2(input:List<String>): Int {
90
-
return0
91
-
}
92
+
funpart2(input:List<String>): Int {
93
+
return0
94
+
}
92
95
93
-
funmain() {
94
96
val input = readInput("Day02")
95
-
part1(input).also(::println)
96
-
part2(input).also(::println)
97
+
println(part1(input))
98
+
println(part2(input))
97
99
}
98
100
```
99
101
@@ -114,4 +116,4 @@ If you stuck with Kotlin-specific questions or anything related to this template
0 commit comments