Skip to content

Commit e5d3fe7

Browse files
committed
Run formatter
1 parent 2d4f17b commit e5d3fe7

File tree

5 files changed

+16
-14
lines changed

5 files changed

+16
-14
lines changed

src/main/kotlin/com/soberg/aoc/utlities/datastructures/Grid2D.kt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package com.soberg.aoc.utlities.datastructures
22

3-
import kotlin.math.absoluteValue
4-
53
/** A uniform 2D grid with elements of type [T]. */
64
data class Grid2D<T>(
75
private val grid: List<List<T>>,
@@ -58,7 +56,7 @@ data class Grid2D<T>(
5856
from: Location,
5957
direction: Direction,
6058
numElementsToCollect: Int,
61-
) : List<T>? {
59+
): List<T>? {
6260
val finalLocation = from.move(direction, numElementsToCollect - 1)
6361
if (!isInBounds(finalLocation)) {
6462
return null
@@ -72,7 +70,7 @@ data class Grid2D<T>(
7270

7371
/** @return Map of elements to list of their respective locations. */
7472
fun elementToLocationsMap(): Map<T, List<Location>> =
75-
filterElementToLocationsMap(filter = { _,_ -> true })
73+
filterElementToLocationsMap(filter = { _, _ -> true })
7674

7775
/** @return Map of elements and their respective locations in the grid that pass [filter]. */
7876
fun filterElementToLocationsMap(
@@ -190,7 +188,7 @@ data class Grid2D<T>(
190188
)
191189

192190
companion object {
193-
infix fun Int.loc(col: Int) : Location = Location(row = this, col = col)
191+
infix fun Int.loc(col: Int): Location = Location(row = this, col = col)
194192
}
195193
}
196194

src/main/kotlin/com/soberg/aoc/utlities/extensions/AsyncSum.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
package com.soberg.aoc.utlities.extensions
22

3-
import kotlinx.coroutines.*
3+
import kotlinx.coroutines.CoroutineDispatcher
4+
import kotlinx.coroutines.Dispatchers
5+
import kotlinx.coroutines.coroutineScope
6+
import kotlinx.coroutines.launch
7+
import kotlinx.coroutines.runBlocking
48
import java.util.concurrent.atomic.AtomicInteger
59
import java.util.concurrent.atomic.AtomicLong
610
import kotlin.experimental.ExperimentalTypeInference
@@ -36,7 +40,7 @@ suspend inline fun <T> Iterable<T>.asyncSumOf(crossinline selector: (T) -> Int):
3640
inline fun <T> Iterable<T>.asyncSumOfBlocking(
3741
dispatcher: CoroutineDispatcher = Dispatchers.Default,
3842
crossinline selector: (T) -> Long,
39-
): Long = runBlocking(dispatcher){
43+
): Long = runBlocking(dispatcher) {
4044
asyncSumOf(selector)
4145
}
4246

src/test/kotlin/com/soberg/aoc/utlities/datastructures/Grid2DLocationTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class Grid2DLocationTest {
6060
@JvmStatic
6161
fun provideArgumentsForDistanceOfOneMove() = listOf(
6262
Arguments.of(Direction.North, Location(9, 10)),
63-
Arguments.of(Direction.NorthEast,Location(9, 11)),
63+
Arguments.of(Direction.NorthEast, Location(9, 11)),
6464
Arguments.of(Direction.East, Location(10, 11)),
6565
Arguments.of(Direction.SouthEast, Location(11, 11)),
6666
Arguments.of(Direction.South, Location(11, 10)),
@@ -72,7 +72,7 @@ class Grid2DLocationTest {
7272
@JvmStatic
7373
fun provideArgumentsForDistanceOfNineMove() = listOf(
7474
Arguments.of(Direction.North, Location(1, 10)),
75-
Arguments.of(Direction.NorthEast,Location(1, 19)),
75+
Arguments.of(Direction.NorthEast, Location(1, 19)),
7676
Arguments.of(Direction.East, Location(10, 19)),
7777
Arguments.of(Direction.SouthEast, Location(19, 19)),
7878
Arguments.of(Direction.South, Location(19, 10)),

src/test/kotlin/com/soberg/aoc/utlities/datastructures/Grid2DTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,8 @@ class Grid2DTest {
238238
@Test
239239
fun `create expected output string when filtering`() {
240240
val grid = listOf(
241-
listOf(1,2,3),
242-
listOf(4,5,6),
241+
listOf(1, 2, 3),
242+
listOf(4, 5, 6),
243243
).toGrid2D()
244244
assertThat(grid.toString { "${grid[it] + 1}," })
245245
.isEqualTo(

src/test/kotlin/com/soberg/aoc/utlities/extensions/AsyncSumTest.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ class AsyncSumTest {
1616

1717
assertThat(letterCount).isEqualTo(36)
1818
}
19-
19+
2020
@Test
21-
fun `return sum of integers - coroutine`() = runTest{
21+
fun `return sum of integers - coroutine`() = runTest {
2222
val letterCount = testData.asyncSumOf {
2323
it.length
2424
}
@@ -36,7 +36,7 @@ class AsyncSumTest {
3636
}
3737

3838
@Test
39-
fun `return sum of longs - coroutine`() = runTest{
39+
fun `return sum of longs - coroutine`() = runTest {
4040
val letterCount = testData.asyncSumOf {
4141
it.length.toLong()
4242
}

0 commit comments

Comments
 (0)