Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite983ec6

Browse files
committed
Simplify the project structure
1 parent417d4c6 commite983ec6

File tree

19 files changed

+66
-214
lines changed

19 files changed

+66
-214
lines changed

‎.github/template-cleanup/README.md‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
![Tests](https://github.com/%REPOSITORY%/workflows/Tests/badge.svg)
2-
31
#%NAME%
42

53
Welcome to the Advent of Code[^aoc] Kotlin project created by[%NAME%][github] using the[Advent of Code Kotlin Template][template] delivered by JetBrains.

‎.github/template-cleanup/gradle.properties‎

Lines changed: 0 additions & 3 deletions
This file was deleted.

‎.github/workflows/template-cleanup.yml‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,8 @@ jobs:
3939
sed -i "s/%REPOSITORY%/${GITHUB_REPOSITORY/\//\\/}/g" .github/template-cleanup/*
4040
sed -i "s/%GROUP%/$GROUP/g" .github/template-cleanup/*
4141
42-
# Replace template package name in project files with $GROUP
43-
find src -type f -exec sed -i "s/com.github.kotlinhandson.aoc/$GROUP/g" {} +
44-
find src -type f -exec sed -i "s/Template/$NAME/g" {} +
45-
find src -type f -exec sed -i "s/JetBrains/$ACTOR/g" {} +
46-
4742
# Move content
48-
mkdir -p src/main/kotlin/${GROUP//.//}
49-
mkdir -p src/test/kotlin/${GROUP//.//}
5043
cp -R .github/template-cleanup/* .
51-
mv src/main/kotlin/com/github/kotlinhandson/aoc/* src/main/kotlin/${GROUP//.//}/
52-
mv src/test/kotlin/com/github/kotlinhandson/aoc/* src/test/kotlin/${GROUP//.//}/
5344
5445
# Cleanup
5546
rm -rf \

‎.github/workflows/tests.yml‎

Lines changed: 0 additions & 28 deletions
This file was deleted.

‎.run/Run All Days.run.xml‎

Lines changed: 0 additions & 23 deletions
This file was deleted.

‎README.md‎

Lines changed: 40 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Right after the [@actions-user][actions-user] actor pushes the second commit to
2020
From now, everything's in your hands!
2121
Join the[Advent of Code][aoc] contest, solve the Day O1 as soon as it is published.
2222

23-
For the following days, copy the`Day01.kt` solution file, its`Day01Test.kt` tests,andname it with an incrementedday.
23+
For the following days, copy the`Day01.kt` solution fileandincrement theday number.
2424

2525
>Remember to join the Kotlin contest!
2626
>
@@ -34,75 +34,66 @@ After you create a new project based on the current template repository using th
3434

3535
```
3636
.
37-
├── README.mdREADME file
38-
├── build.gradle.ktsGradle configuration created with Kotlin DSL
37+
├── README.md README file
38+
├── build.gradle.kts Gradle configuration created with Kotlin DSL
3939
├── gradle
40-
│ └── wrapperGradle Wrapper
41-
├── gradle.propertiesGradle configuration properties
42-
├── gradlew*nix Gradle Wrapper script
43-
├── gradlew.batWindows Gradle Wrapper script
44-
├── settings.gradle.ktsGradle project settings
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
4545
└── 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
46+
├── Day01.kt An empty implementation for the first AoC day
47+
├── Day01.txt An empty file for the Day 01 input data
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
6150
```
6251

63-
After the first puzzle appears, go to the`Day01.kt` and for each`part1` and`part2`classes, provide an algorithm implementation using theprovided`input` data loaded from the`day01.txt` file.
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.
6453
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.
6554

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:
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:
6756

6857
```kotlin
69-
classDay01 :Day(1) {
70-
71-
overridefunpart1(input:String):Int {
72-
return input.ints().sum()
73-
}
58+
funpart1(input:List<String>):Int {
59+
return input.size
60+
}
7461

75-
// ...
62+
funmain() {
63+
val input= readInput("Day01")
64+
part1(input).also(::println)
7665
}
7766
```
7867

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.
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].
8369

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:
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+
To handle that case, you can put such an input into a separated file and perform a standard assertion against the output, like:
8572

8673
```kotlin
87-
classDay02 :Day(2) {
88-
// ...
74+
funmain() {
75+
val testInput= readInput("Day01_test")
76+
assert(part1(testInput)==13)
8977
}
9078
```
9179

92-
Then just provide tests for the second day in a similar manner:
80+
The final result of your algorithm will be printed on the screen so that you can pass it to the Advent of Code website.
81+
82+
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:
9383

9484
```kotlin
95-
classDay02Test :DayTest() {
96-
97-
overrideval day=Day02()
85+
funpart1(input:List<String>):Int {
86+
return0
87+
}
9888

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-
}
89+
funpart2(input:List<String>):Int {
90+
return0
91+
}
10492

105-
// ...
93+
funmain() {
94+
val input= readInput("Day02")
95+
part1(input).also(::println)
96+
part2(input).also(::println)
10697
}
10798
```
10899

@@ -123,4 +114,4 @@ If you stuck with Kotlin-specific questions or anything related to this template
123114
[kotlin]:https://kotlinlang.org
124115
[slack]:https://surveys.jetbrains.com/s3/kotlin-slack-sign-up
125116
[file:kotlin]:.github/readme/kotlin.svg
126-
[file:utils]:src/main/kotlin/com/github/kotlinhandson/aoc/utils/utils.kt
117+
[file:utils]:src/utils.kt

‎build.gradle.kts‎

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,18 @@ plugins {
22
kotlin("jvm") version"1.6.0"
33
}
44

5-
group= project.property("group").toString()
6-
version= project.property("version").toString()
7-
8-
dependencies {
9-
testImplementation(kotlin("test"))
10-
}
11-
125
repositories {
136
mavenCentral()
147
}
158

169
tasks {
17-
withType<Test> {
18-
useJUnitPlatform()
10+
sourceSets {
11+
main {
12+
java.srcDirs("src")
13+
}
1914
}
2015

2116
wrapper {
22-
gradleVersion=project.findProperty("gradleVersion").toString()
17+
gradleVersion="7.3"
2318
}
2419
}

‎gradle.properties‎

Lines changed: 0 additions & 3 deletions
This file was deleted.

‎gradle/wrapper/gradle-wrapper.jar‎

-58.1 KB
Binary file not shown.

‎gradle/wrapper/gradle-wrapper.properties‎

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp