Skip to content

Commit d79dd40

Browse files
committed
Convert CRLF to LF
Some files still had Windows line endings. Now all should have Unix ones.
1 parent ae4e28b commit d79dd40

File tree

16 files changed

+1070
-1070
lines changed

16 files changed

+1070
-1070
lines changed
Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
name: Dependency Submission
2-
3-
on:
4-
push:
5-
branches: [ 'main' ]
6-
7-
permissions:
8-
contents: write
9-
10-
jobs:
11-
dependency-submission:
12-
runs-on: ubuntu-latest
13-
steps:
14-
- name: Checkout sources
15-
uses: actions/checkout@v4
16-
- name: Setup Java
17-
uses: actions/setup-java@v4
18-
with:
19-
distribution: 'temurin'
20-
java-version: 21
21-
- name: Generate and submit dependency graph
22-
uses: gradle/actions/dependency-submission@v4
1+
name: Dependency Submission
2+
3+
on:
4+
push:
5+
branches: [ 'main' ]
6+
7+
permissions:
8+
contents: write
9+
10+
jobs:
11+
dependency-submission:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout sources
15+
uses: actions/checkout@v4
16+
- name: Setup Java
17+
uses: actions/setup-java@v4
18+
with:
19+
distribution: 'temurin'
20+
java-version: 21
21+
- name: Generate and submit dependency graph
22+
uses: gradle/actions/dependency-submission@v4

.github/workflows/gradle-build.yml

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
name: Build
2-
3-
on: [ push ]
4-
5-
jobs:
6-
build:
7-
runs-on: ubuntu-latest
8-
steps:
9-
- name: Checkout sources
10-
uses: actions/checkout@v4
11-
- name: Setup Java
12-
uses: actions/setup-java@v4
13-
with:
14-
distribution: 'temurin'
15-
java-version: 21
16-
- name: Setup Gradle
17-
uses: gradle/actions/setup-gradle@v4
18-
- name: Build with Gradle
19-
run: ./gradlew build
1+
name: Build
2+
3+
on: [ push ]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Checkout sources
10+
uses: actions/checkout@v4
11+
- name: Setup Java
12+
uses: actions/setup-java@v4
13+
with:
14+
distribution: 'temurin'
15+
java-version: 21
16+
- name: Setup Gradle
17+
uses: gradle/actions/setup-gradle@v4
18+
- name: Build with Gradle
19+
run: ./gradlew build

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
org.gradle.configuration-cache=true
1+
org.gradle.configuration-cache=true
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
package de.ronny_h.aoc.extensions
2-
3-
fun <T, R> ((T) -> R).memoize(): ((T) -> R) {
4-
val original = this
5-
val cache = mutableMapOf<T, R>()
6-
return { n: T ->
7-
cache.getOrPut(n) { original(n) }
8-
}
9-
}
1+
package de.ronny_h.aoc.extensions
2+
3+
fun <T, R> ((T) -> R).memoize(): ((T) -> R) {
4+
val original = this
5+
val cache = mutableMapOf<T, R>()
6+
return { n: T ->
7+
cache.getOrPut(n) { original(n) }
8+
}
9+
}
Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
package de.ronny_h.aoc.extensions
2-
3-
4-
/**
5-
* @return All pairwise combinations of list elements without the reflexive ones.
6-
*/
7-
fun <E> List<E>.combinations() = sequence {
8-
forEachIndexed { i, a ->
9-
forEachIndexed { j, b ->
10-
if (i != j) {
11-
yield(a to b)
12-
}
13-
}
14-
}
15-
}
1+
package de.ronny_h.aoc.extensions
2+
3+
4+
/**
5+
* @return All pairwise combinations of list elements without the reflexive ones.
6+
*/
7+
fun <E> List<E>.combinations() = sequence {
8+
forEachIndexed { i, a ->
9+
forEachIndexed { j, b ->
10+
if (i != j) {
11+
yield(a to b)
12+
}
13+
}
14+
}
15+
}
Lines changed: 87 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,87 @@
1-
package de.ronny_h.aoc.extensions
2-
3-
import kotlin.math.abs
4-
5-
data class Coordinates(val row: Int, val col: Int) {
6-
operator fun plus(other: Coordinates) = Coordinates(row + other.row, col + other.col)
7-
operator fun minus(other: Coordinates) = Coordinates(row - other.row, col - other.col)
8-
9-
operator fun times(other: Int) = Coordinates(row * other, col * other)
10-
11-
operator fun plus(direction: Direction) = Coordinates(row + direction.row, col + direction.col)
12-
13-
fun neighbours() = listOf(this + Direction.EAST, this + Direction.SOUTH, this + Direction.WEST, this + Direction.NORTH)
14-
fun directedNeighbours() = listOf(
15-
Direction.EAST to this + Direction.EAST,
16-
Direction.SOUTH to this + Direction.SOUTH,
17-
Direction.WEST to this + Direction.WEST,
18-
Direction.NORTH to this + Direction.NORTH,
19-
)
20-
21-
/**
22-
* Calculates the taxi distance, a.k.a. Manhattan distance, between this and the other Coordinates instance.
23-
*/
24-
infix fun taxiDistanceTo(other: Coordinates): Int = abs(other.col - col) + abs(other.row - row)
25-
26-
override fun toString() = "($row,$col)"
27-
}
28-
29-
operator fun Int.times(other: Coordinates) = Coordinates(this * other.row, this * other.col)
30-
31-
enum class Direction(val row: Int, val col: Int) {
32-
NORTH(-1, 0),
33-
EAST(0, +1),
34-
SOUTH(+1, 0),
35-
WEST(0, -1),
36-
;
37-
38-
fun turnRight() = when (this) {
39-
NORTH -> EAST
40-
EAST -> SOUTH
41-
SOUTH -> WEST
42-
WEST -> NORTH
43-
}
44-
45-
fun turnLeft() = when (this) {
46-
NORTH -> WEST
47-
EAST -> NORTH
48-
SOUTH -> EAST
49-
WEST -> SOUTH
50-
}
51-
52-
fun asChar() = when (this) {
53-
NORTH -> ''
54-
EAST -> ''
55-
SOUTH -> ''
56-
WEST -> ''
57-
}
58-
59-
fun isHorizontal(): Boolean = this == EAST || this == WEST
60-
fun isVertical(): Boolean = this == NORTH || this == SOUTH
61-
62-
fun isOpposite(other: Direction) = when (this) {
63-
NORTH -> other == SOUTH
64-
EAST -> other == WEST
65-
SOUTH -> other == NORTH
66-
WEST -> other == EAST
67-
}
68-
69-
/**
70-
* Returns the minimal number of 90° rotations necessary to rotate this
71-
* to other.
72-
*/
73-
operator fun minus(other: Direction): Int {
74-
return when {
75-
this == other -> 0
76-
this.isOpposite(other) -> 2
77-
else -> 1
78-
}
79-
}
80-
81-
override fun toString() = when (this) {
82-
NORTH -> "N"
83-
EAST -> "E"
84-
SOUTH -> "S"
85-
WEST -> "W"
86-
}
87-
}
1+
package de.ronny_h.aoc.extensions
2+
3+
import kotlin.math.abs
4+
5+
data class Coordinates(val row: Int, val col: Int) {
6+
operator fun plus(other: Coordinates) = Coordinates(row + other.row, col + other.col)
7+
operator fun minus(other: Coordinates) = Coordinates(row - other.row, col - other.col)
8+
9+
operator fun times(other: Int) = Coordinates(row * other, col * other)
10+
11+
operator fun plus(direction: Direction) = Coordinates(row + direction.row, col + direction.col)
12+
13+
fun neighbours() = listOf(this + Direction.EAST, this + Direction.SOUTH, this + Direction.WEST, this + Direction.NORTH)
14+
fun directedNeighbours() = listOf(
15+
Direction.EAST to this + Direction.EAST,
16+
Direction.SOUTH to this + Direction.SOUTH,
17+
Direction.WEST to this + Direction.WEST,
18+
Direction.NORTH to this + Direction.NORTH,
19+
)
20+
21+
/**
22+
* Calculates the taxi distance, a.k.a. Manhattan distance, between this and the other Coordinates instance.
23+
*/
24+
infix fun taxiDistanceTo(other: Coordinates): Int = abs(other.col - col) + abs(other.row - row)
25+
26+
override fun toString() = "($row,$col)"
27+
}
28+
29+
operator fun Int.times(other: Coordinates) = Coordinates(this * other.row, this * other.col)
30+
31+
enum class Direction(val row: Int, val col: Int) {
32+
NORTH(-1, 0),
33+
EAST(0, +1),
34+
SOUTH(+1, 0),
35+
WEST(0, -1),
36+
;
37+
38+
fun turnRight() = when (this) {
39+
NORTH -> EAST
40+
EAST -> SOUTH
41+
SOUTH -> WEST
42+
WEST -> NORTH
43+
}
44+
45+
fun turnLeft() = when (this) {
46+
NORTH -> WEST
47+
EAST -> NORTH
48+
SOUTH -> EAST
49+
WEST -> SOUTH
50+
}
51+
52+
fun asChar() = when (this) {
53+
NORTH -> ''
54+
EAST -> ''
55+
SOUTH -> ''
56+
WEST -> ''
57+
}
58+
59+
fun isHorizontal(): Boolean = this == EAST || this == WEST
60+
fun isVertical(): Boolean = this == NORTH || this == SOUTH
61+
62+
fun isOpposite(other: Direction) = when (this) {
63+
NORTH -> other == SOUTH
64+
EAST -> other == WEST
65+
SOUTH -> other == NORTH
66+
WEST -> other == EAST
67+
}
68+
69+
/**
70+
* Returns the minimal number of 90° rotations necessary to rotate this
71+
* to other.
72+
*/
73+
operator fun minus(other: Direction): Int {
74+
return when {
75+
this == other -> 0
76+
this.isOpposite(other) -> 2
77+
else -> 1
78+
}
79+
}
80+
81+
override fun toString() = when (this) {
82+
NORTH -> "N"
83+
EAST -> "E"
84+
SOUTH -> "S"
85+
WEST -> "W"
86+
}
87+
}

0 commit comments

Comments
 (0)