Skip to content
Snippets Groups Projects
Commit f797f6ec authored by Jonas's avatar Jonas
Browse files

Upgrade Gradle and linked stuff :sparkles:

Upgrade AGP dependency from 3.2.1 to 7.3.1
Upgrade Gradle version to 7.4
Upgrade Gradle plugins
Update default Java language level
Move package from Android manifest to build files
parent 62afd00d
No related branches found
No related tags found
No related merge requests found
Showing
with 18 additions and 32 deletions
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<component name="GradleSettings"> <component name="GradleSettings">
<option name="linkedExternalProjectsSettings"> <option name="linkedExternalProjectsSettings">
<GradleProjectSettings> <GradleProjectSettings>
<option name="testRunner" value="PLATFORM" /> <option name="testRunner" value="GRADLE" />
<option name="distributionType" value="DEFAULT_WRAPPED" /> <option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" /> <option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="modules"> <option name="modules">
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
<option value="$PROJECT_DIR$/app" /> <option value="$PROJECT_DIR$/app" />
</set> </set>
</option> </option>
<option name="resolveModulePerSourceSet" value="false" />
</GradleProjectSettings> </GradleProjectSettings>
</option> </option>
</component> </component>
......
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
</value> </value>
</option> </option>
</component> </component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="Embedded JDK" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" /> <output url="file://$PROJECT_DIR$/build/classes" />
</component> </component>
<component name="ProjectType"> <component name="ProjectType">
......
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
<option value="com.android.tools.idea.compose.preview.runconfiguration.ComposePreviewRunConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
</set>
</option>
</component>
</project>
\ No newline at end of file
...@@ -20,6 +20,7 @@ android { ...@@ -20,6 +20,7 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
} }
} }
namespace 'app.jonas.adventofcode2020'
} }
dependencies { dependencies {
......
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android">
package="app.jonas.adventofcode2020">
<application android:allowBackup="true" <application android:allowBackup="true"
android:label="@string/app_name" android:label="@string/app_name"
android:icon="@mipmap/ic_launcher" android:icon="@mipmap/ic_launcher"
......
...@@ -45,13 +45,13 @@ fun extractSleepRanges(entries: List<Entry>): MutableMap<Int, MutableList<IntRan ...@@ -45,13 +45,13 @@ fun extractSleepRanges(entries: List<Entry>): MutableMap<Int, MutableList<IntRan
fun sleepiestMinute(ranges: List<IntRange>) = fun sleepiestMinute(ranges: List<IntRange>) =
(0..59).map { it to ranges.fold(0) { acc, range -> if (it in range) acc + 1 else acc } } (0..59).map { it to ranges.fold(0) { acc, range -> if (it in range) acc + 1 else acc } }
.maxBy { (_, count) -> count } .maxByOrNull { (_, count) -> count }
?: throw IllegalArgumentException("Sleepiest min not parsable") ?: throw IllegalArgumentException("Sleepiest min not parsable")
fun part1(file: File): Int { fun part1(file: File): Int {
val sortedInput = parseInput(file).sorted() val sortedInput = parseInput(file).sorted()
val sleepRanges = extractSleepRanges(sortedInput) val sleepRanges = extractSleepRanges(sortedInput)
val (id, ranges) = sleepRanges.maxBy { (_, ranges) -> ranges.fold(0) { acc, r -> acc + r.count() } } val (id, ranges) = sleepRanges.maxByOrNull { (_, ranges) -> ranges.fold(0) { acc, r -> acc + r.count() } }
?: throw IllegalArgumentException("Sleep ranges not parsable") ?: throw IllegalArgumentException("Sleep ranges not parsable")
return id * sleepiestMinute(ranges).first return id * sleepiestMinute(ranges).first
} }
...@@ -62,6 +62,6 @@ fun part2(file: File): Int { ...@@ -62,6 +62,6 @@ fun part2(file: File): Int {
val (id, min) = sleepRanges.map { (id, ranges) -> val (id, min) = sleepRanges.map { (id, ranges) ->
val (minute, count) = sleepiestMinute(ranges) val (minute, count) = sleepiestMinute(ranges)
Triple(id, minute, count) Triple(id, minute, count)
}.maxBy { (_, _, count) -> count } ?: throw IllegalArgumentException("Sleep ranges not parsable") }.maxByOrNull { (_, _, count) -> count } ?: throw IllegalArgumentException("Sleep ranges not parsable")
return id * min return id * min
} }
\ No newline at end of file
...@@ -42,5 +42,5 @@ fun part2(file: File): Int? { ...@@ -42,5 +42,5 @@ fun part2(file: File): Int? {
val input = file.readLines().single() val input = file.readLines().single()
return input.toList().distinctBy { it.toLowerCase() } return input.toList().distinctBy { it.toLowerCase() }
.map { react(input.replace(it.toString(), "", true)).length } .map { react(input.replace(it.toString(), "", true)).length }
.min() .minOrNull()
} }
...@@ -46,7 +46,7 @@ fun part1(file: File): Int { ...@@ -46,7 +46,7 @@ fun part1(file: File): Int {
} }
} }
infinite.forEach { counts.remove(it) } infinite.forEach { counts.remove(it) }
return counts.values.max() ?: throw IllegalArgumentException("Max not found") return counts.values.maxOrNull() ?: throw IllegalArgumentException("Max not found")
} }
fun part2(file: File, maxDistance: Int): Int { fun part2(file: File, maxDistance: Int): Int {
......
...@@ -87,7 +87,7 @@ fun part2(file: File, workerCount: Int, additionalStepDuration: Int): Int { ...@@ -87,7 +87,7 @@ fun part2(file: File, workerCount: Int, additionalStepDuration: Int): Int {
second += if (someoneFinished) { second += if (someoneFinished) {
1 1
} else { } else {
val minWorkingTime = workers.mapNotNull { it.timeLeft(second) }.min() val minWorkingTime = workers.mapNotNull { it.timeLeft(second) }.minOrNull()
minWorkingTime ?: throw Error("Nobody is working: shouldn't happen!") minWorkingTime ?: throw Error("Nobody is working: shouldn't happen!")
} }
} }
......
...@@ -48,7 +48,7 @@ private fun getHighscore(file: File, lastMarbleValueMultiplier: Int = 1): Long { ...@@ -48,7 +48,7 @@ private fun getHighscore(file: File, lastMarbleValueMultiplier: Int = 1): Long {
next.previous = currentMarble next.previous = currentMarble
} }
} }
return scores.max() ?: throw Error("No highscore!") return scores.maxOrNull() ?: throw Error("No highscore!")
} }
fun part1(file: File)= getHighscore(file) fun part1(file: File)= getHighscore(file)
......
...@@ -66,7 +66,7 @@ fun part1(serialNumber: Int): String { ...@@ -66,7 +66,7 @@ fun part1(serialNumber: Int): String {
fun part2(serialNumber: Int): String { fun part2(serialNumber: Int): String {
val plane = getPowerLevelPlane(serialNumber) val plane = getPowerLevelPlane(serialNumber)
val largestTotalPowers = (1..300).map { size -> size to plane.sumWindowed(size).getLargestTotalPower() } val largestTotalPowers = (1..300).map { size -> size to plane.sumWindowed(size).getLargestTotalPower() }
val (size, largestTotalPower) = largestTotalPowers.maxBy { (_, largestTotalPower) -> largestTotalPower.second } val (size, largestTotalPower) = largestTotalPowers.maxByOrNull { (_, largestTotalPower) -> largestTotalPower.second }
?: throw Error("No maximum found!") ?: throw Error("No maximum found!")
val (coordinates) = largestTotalPower val (coordinates) = largestTotalPower
return "$coordinates,$size" return "$coordinates,$size"
......
...@@ -16,7 +16,7 @@ fun boardingPassToSeatID(boardingPass: String): Int {// BFFFBBFRRR ...@@ -16,7 +16,7 @@ fun boardingPassToSeatID(boardingPass: String): Int {// BFFFBBFRRR
return row * 8 + column return row * 8 + column
} }
fun part1(file: File) = file.readLines().map(::boardingPassToSeatID).max() fun part1(file: File) = file.readLines().maxOfOrNull(::boardingPassToSeatID)
fun part2(file: File): Int { fun part2(file: File): Int {
val seatIDs = file.readLines().map(::boardingPassToSeatID) val seatIDs = file.readLines().map(::boardingPassToSeatID)
......
...@@ -42,5 +42,5 @@ fun part2(file: File, preamble: Int): Long { ...@@ -42,5 +42,5 @@ fun part2(file: File, preamble: Int): Long {
} }
} }
val contiguousSummands = numbers.subList(startIndex, endIndex) val contiguousSummands = numbers.subList(startIndex, endIndex)
return contiguousSummands.max()!! + contiguousSummands.min()!! return contiguousSummands.maxOrNull()!! + contiguousSummands.minOrNull()!!
} }
...@@ -12,7 +12,7 @@ class ShuttleSearchTest { ...@@ -12,7 +12,7 @@ class ShuttleSearchTest {
fun testPart1Input() = assertEquals(4782, part1(load("input.txt"))) fun testPart1Input() = assertEquals(4782, part1(load("input.txt")))
@Test @Test
fun testPart2Example() = assertEquals(1068781, part2(load("example.txt"))) fun testPart2Example() = assertEquals(1068781.toBigInteger(), part2(load("example.txt")))
@Test @Test
fun testPart2Input() = assertEquals(1118684865113056.toBigInteger(), part2(load("input.txt"))) fun testPart2Input() = assertEquals(1118684865113056.toBigInteger(), part2(load("input.txt")))
......
// Top-level build file where you can add configuration options common to all sub-projects/modules. // Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript { buildscript {
ext.kotlin_version = '1.2.71' ext.kotlin_version = '1.6.21'
repositories { repositories {
google() google()
jcenter() jcenter()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:3.2.1' classpath 'com.android.tools.build:gradle:7.3.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong // NOTE: Do not place your application dependencies here; they belong
......
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.8.1-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment