From ba5c1dcecf77a9b09e88570ab1c5ba2859912ebb Mon Sep 17 00:00:00 2001 From: Daniel Lin Date: Mon, 2 Dec 2024 05:44:01 -0500 Subject: [PATCH] Minor tweaks --- kt/README.md | 2 +- rs/src/day2.rs | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/kt/README.md b/kt/README.md index f2d07ac..cf8e9ea 100644 --- a/kt/README.md +++ b/kt/README.md @@ -18,7 +18,7 @@ Run [kotlinx.benchmark](https://github.com/Kotlin/kotlinx-benchmark) ([JMH](http Print solutions for the inputs provided in local data files: ```sh -./gradlew :aoc2024-exe:jvmRun :aoc2024-exe:runReleaseExecutable{LinuxX64,Macos{X64,Arm64}} :aoc2024-exe:jsNodeProductionRun +./gradlew :aoc2024-exe:jvmRun :aoc2024-exe:runReleaseExecutable{LinuxX64,Macos{X64,Arm64}} :aoc2024-exe:{js,wasmJs}NodeProductionRun ``` Run all checks, including [Detekt](https://detekt.github.io/) static code analysis: diff --git a/rs/src/day2.rs b/rs/src/day2.rs index 2542e34..1a756f2 100644 --- a/rs/src/day2.rs +++ b/rs/src/day2.rs @@ -26,8 +26,7 @@ fn is_safe_2(report: &[i32]) -> bool { if report.is_empty() { return true; } - let mut report2 = vec![0; report.len() - 1]; - report2.copy_from_slice(&report[1..]); + let mut report2 = report[1..].to_vec(); is_safe_1(&report2) || (0..report2.len()).any(|i| { report2[i] = report[i];