Skip to content

Commit 4958a4e

Browse files
committed
Merge remote-tracking branch 'upstream/main'
# Conflicts: # build.gradle.kts
2 parents f7f214b + a193b69 commit 4958a4e

File tree

9 files changed

+44
-18
lines changed

9 files changed

+44
-18
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
.gradle
22
.idea
3+
.kotlin/
34
build
45
src/**/*.txt
6+
local.properties

.idea/fileTemplates/Advent of Code.kt

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Advent of Code Kotlin Template
22

33
[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.
4+
Every year since then, with the first day of December, a programming puzzles contest is published every day for twenty-five days.
55
A set of Christmas-oriented challenges provides any input you have to use to answer using the language of your choice.
66
We offer you a template prepared to use with [Kotlin][kotlin] language within this repository.
77

@@ -44,7 +44,7 @@ Copy the `Day01.kt` solution file for the following days and increment the day n
4444
>
4545
> Remember to join the Kotlin contest!
4646
>
47-
> To do that, edit your project's _About_ section with ⚙️ icon and add the `aoc-2023-in-kotlin` topic to your project.
47+
> To do that, edit your project's _About_ section with ⚙️ icon and add the `aoc-2024-in-kotlin` topic to your project.
4848
>
4949
> **We will find your repository and count you in our giveaway.**
5050

gradle/wrapper/gradle-wrapper.jar

121 Bytes
Binary file not shown.

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

gradlew

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
# See the License for the specific language governing permissions and
1616
# limitations under the License.
1717
#
18+
# SPDX-License-Identifier: Apache-2.0
19+
#
1820

1921
##############################################################################
2022
#
@@ -55,7 +57,7 @@
5557
# Darwin, MinGW, and NonStop.
5658
#
5759
# (3) This script is generated from the Groovy template
58-
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
60+
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
5961
# within the Gradle project.
6062
#
6163
# You can find Gradle at https://github.com/gradle/gradle/.
@@ -84,7 +86,8 @@ done
8486
# shellcheck disable=SC2034
8587
APP_BASE_NAME=${0##*/}
8688
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
87-
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
89+
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
90+
' "$PWD" ) || exit
8891

8992
# Use the maximum available, or set MAX_FD != -1 to use that value.
9093
MAX_FD=maximum

gradlew.bat

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
@rem See the License for the specific language governing permissions and
1414
@rem limitations under the License.
1515
@rem
16+
@rem SPDX-License-Identifier: Apache-2.0
17+
@rem
1618

1719
@if "%DEBUG%"=="" @echo off
1820
@rem ##########################################################################
@@ -43,11 +45,11 @@ set JAVA_EXE=java.exe
4345
%JAVA_EXE% -version >NUL 2>&1
4446
if %ERRORLEVEL% equ 0 goto execute
4547

46-
echo.
47-
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
48-
echo.
49-
echo Please set the JAVA_HOME variable in your environment to match the
50-
echo location of your Java installation.
48+
echo. 1>&2
49+
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
50+
echo. 1>&2
51+
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
52+
echo location of your Java installation. 1>&2
5153

5254
goto fail
5355

@@ -57,11 +59,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
5759

5860
if exist "%JAVA_EXE%" goto execute
5961

60-
echo.
61-
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
62-
echo.
63-
echo Please set the JAVA_HOME variable in your environment to match the
64-
echo location of your Java installation.
62+
echo. 1>&2
63+
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
64+
echo. 1>&2
65+
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
66+
echo location of your Java installation. 1>&2
6567

6668
goto fail
6769

src/Day01.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,14 @@ fun main() {
77
return input.size
88
}
99

10-
// test if implementation meets criteria from the description, like:
10+
// Test if implementation meets criteria from the description, like:
11+
check(part1(listOf("test_input")) == 1)
12+
13+
// Or read a large test input from the `src/Day01_test.txt` file:
1114
val testInput = readInput("Day01_test")
1215
check(part1(testInput) == 1)
1316

17+
// Read the input from the `src/Day01.txt` file.
1418
val input = readInput("Day01")
1519
part1(input).println()
1620
part2(input).println()

src/Utils.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import java.math.BigInteger
22
import java.security.MessageDigest
33
import kotlin.io.path.Path
4-
import kotlin.io.path.readLines
4+
import kotlin.io.path.readText
55

66
/**
77
* Reads lines from the given input txt file.
88
*/
9-
fun readInput(name: String) = Path("src/$name.txt").readLines()
9+
fun readInput(name: String) = Path("src/$name.txt").readText().trim().lines()
1010

1111
/**
1212
* Converts string to md5 hash.

0 commit comments

Comments
 (0)